Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

xyBalance chalenge

Hi,
I am working on below challenge
http://codingbat.com/prob/p134250
I tried my code as below
public boolean xyBalance(String str) { 

 int xPos= str.indexOf('x');
 int yPos= str.indexOf('y');

 if(xPos>=0&&yPos>=0){
 return true;
 }
 else{
 return false;
 }


}

Open in new window

I am getting below result
Expected      Run            
xyBalance("aaxbby") → true      true      OK         
xyBalance("aaxbb") → false      false      OK         
xyBalance("yaaxbb") → false      true      X         
xyBalance("yaaxbby") → true      true      OK         
xyBalance("xaxxbby") → true      true      OK         
xyBalance("xaxxbbyx") → false      true      X         
xyBalance("xxbxy") → true      true      OK         
xyBalance("xxbx") → false      false      OK         
xyBalance("bbb") → true      false      X         
xyBalance("bxbb") → false      false      OK         
xyBalance("bxyb") → true      true      OK         
xyBalance("xy") → true      true      OK         
xyBalance("y") → true      false      X         
xyBalance("x") → false      false      OK         
xyBalance("") → true      false      X         
xyBalance("yxyxyxyx") → false      true      X         
xyBalance("yxyxyxyxy") → true      true      OK         
xyBalance("12xabxxydxyxyzz") → true

how to  improve my approach, results and design of this challenge. How do i make a graphical venn or flow chart or some other relevant diagram to design it before writing code to decide best strategy?
 Please advise
Avatar of ozo
ozo
Flag of United States of America image

return !str.matches(".*x[^y]*");
SOLUTION
Avatar of awking00
awking00
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

We'll say that a String is xy-balanced if for all the 'x' chars in the string, there exists a 'y' char somewhere later in the string. So "xxy" is balanced, but "xyx" is not.

i am not clear on this challenge.

So "xxy" is balanced, but "xyx" is not

how xxy is balance there are 2 x's and only 1 y's right and 2 is not equal to 1 so not balanced right?

so total number of X's should be equal to total number of Y's then balanced is true accoring to challenge???

not sure why below is false?( as number of x's is one and number of y's is1 which seems balanced to me??)
xyBalance("yaaxbb") → false
I think it was a poor choice of words to use "balanced" to define the challenge criteria. The number of x's and y's has nothing to do with the string being balanced. It's considered to be balanced when each and every x is later followed by a y. So xxxxxxxxxy would be balanced and xyyyyyyyyx would not.
With "yaaxbb" there is no y after the x and with "xyx" there is no y after all x's.
Avatar of gudii9

ASKER

It's considered to be balanced when each and every x is later followed by a y. So xxxxxxxxxy would be balanced
xxxxxxxxxy
above highlighted x does not followed by y(instead it is followed by another x as italicized and underlined??
You're not understanding how the challenge defines the criteria for being balanced. It states,

String is xy-balanced if for all the 'x' chars in the string, there exists a 'y' char somewhere later in the string
and One 'y' can balance multiple 'x's
So with xxxxxxxxxy , the first x is followed later by a y, the second x is followed later by a y (happens to be the same y), the third x ....etc. All of the x's are followed later by the same y.
http:#a41439798
return str.indexOf("x") > 0 && str.lastIndexOf("y") > str.lastIndexOf("x");
Close.


Instead:
return str.indexOf("x") < 0 || str.lastIndexOf("y") > str.lastIndexOf("x");
or
return str.lastIndexOf("y") >= str.lastIndexOf("x");
Avatar of gudii9

ASKER

I got meaning of challenge
Avatar of gudii9

ASKER

public boolean xyBalance(String str) { 
  

 
 
for(int i=0;i<str.length();i++){
 int xPos= str.indexOf('x');
 int yPos= str.indexOf('y');
 int len=str.length();
 

 if(xPos>=0&&yPos>=0&&(yPos>xPos)){
 return true;
 }

}

return false;

}

Open in new window


above fails below.

Expected	Run		
xyBalance("aaxbby") → true	true	OK	    
xyBalance("aaxbb") → false	false	OK	    
xyBalance("yaaxbb") → false	false	OK	    
xyBalance("yaaxbby") → true	false	X	    
xyBalance("xaxxbby") → true	true	OK	    
xyBalance("xaxxbbyx") → false	true	X	    
xyBalance("xxbxy") → true	true	OK	    
xyBalance("xxbx") → false	false	OK	    
xyBalance("bbb") → true	false	X	    
xyBalance("bxbb") → false	false	OK	    
xyBalance("bxyb") → true	true	OK	    
xyBalance("xy") → true	true	OK	    
xyBalance("y") → true	false	X	    
xyBalance("x") → false	false	OK	    
xyBalance("") → true	false	X	    
xyBalance("yxyxyxyx") → false	false	OK	    
xyBalance("yxyxyxyxy") → true	false	X	    
xyBalance("12xabxxydxyxyzz") → true	true	OK	    
other tests
X	    
Correct for more than half the tests

Open in new window

please advise
for all the 'x' chars in the string, there exists a 'y' char somewhere later in the string
xyBalance("yaaxbby") → true      false      X      
xyBalance("y") → true      false      X      
xyBalance("yxyxyxyxy") → true      false      X      
xyBalance("") → true      false      X      
for all the 'x' characters, there exists a 'y' char somewhere later in the string

xyBalance("xaxxbbyx") → false      true      X      
for this x character, there does not exist a 'y' char somewhere later in the string
Avatar of gudii9

ASKER

xyBalance("yaaxbby") → true      false      X      
xyBalance("y") → true      false      X      
xyBalance("yxyxyxyxy") → true      false      X      
xyBalance("") → true      false      X      
for all the 'x' characters, there exists a 'y' char somewhere later in the string

xyBalance("xaxxbbyx") → false      true      X      
for this x character, there does not exist a 'y' char somewhere later in the string

i got the description of the challenge but i have not understood why my code approach is failing some tests?

public boolean xyBalance(String str) { 
  

 
 
for(int i=0;i<str.length();i++){
 int xPos= str.indexOf('x');
 int yPos= str.indexOf('y');
 int len=str.length();
 

 if(xPos>=0&&yPos>=0&&(yPos>xPos)){
 return true;
 }

}

return false;

}

Open in new window


i am checking y should be always lter compared to x by getting index positions of them

 if(xPos>=0&&yPos>=0&&(yPos>xPos)){
Avatar of gudii9

ASKER

as below
public boolean xyBalance(String str) { 
  

 
 
for(int i=0;i<str.length();i++){
 int xPos= str.indexOf('x');
 int yPos= str.indexOf('y');
 int len=str.length();
 

 if(xPos>=0&&yPos>=0&&(yPos>xPos)){
 return true;
 }

}

return false;

}

Open in new window



Expected	Run		
xyBalance("aaxbby") → true	true	OK	    
xyBalance("aaxbb") → false	false	OK	    
xyBalance("yaaxbb") → false	false	OK	    
xyBalance("yaaxbby") → true	false	X	    
xyBalance("xaxxbby") → true	true	OK	    
xyBalance("xaxxbbyx") → false	true	X	    
xyBalance("xxbxy") → true	true	OK	    
xyBalance("xxbx") → false	false	OK	    
xyBalance("bbb") → true	false	X	    
xyBalance("bxbb") → false	false	OK	    
xyBalance("bxyb") → true	true	OK	    
xyBalance("xy") → true	true	OK	    
xyBalance("y") → true	false	X	    
xyBalance("x") → false	false	OK	    
xyBalance("") → true	false	X	    
xyBalance("yxyxyxyx") → false	false	OK	    
xyBalance("yxyxyxyxy") → true	false	X	    
xyBalance("12xabxxydxyxyzz") → true	true	OK	    
other tests
X	    
Correct for more than half the tests

Open in new window

Avatar of gudii9

ASKER

public class XyBalanace {
	public static void main(String[] args) {
		System.out.println("Values is--->"+xyBalance("yaaxbby")); 
	}

	public static boolean xyBalance(String str) { 
	  
	
	 
	 
	for(int i=0;i<str.length();i++){
	 int xPos= str.indexOf('x');
	 int yPos= str.indexOf('y');
	 int len=str.length();
	 
	
	 if(xPos>=0&&yPos>=0&&(yPos>xPos)){
	 return true;
	 }
	
	}
	
	return false;
	
	}
}

Open in new window


i expected above true not sure why false coming as below
Values is--->false
Avatar of gudii9

ASKER

public class XyBalanace {
	public static void main(String[] args) {
		System.out.println("Values is--->"+xyBalance("yaaxbby")); 
	}

	public static boolean xyBalance(String str) { 
	  
	
	 
	 
	for(int i=0;i<str.length()-1;i++){
	 int xPos= str.indexOf('x');
	 int yPos= str.indexOf('y');
	 int len=str.length();
	 
	
	 if(xPos>=0&&yPos>=0&&(yPos>xPos)){
	 return true;
	 }
	
	}
	
	return false;
	
	}
}

Open in new window


making str.length()-1 also did not help
int xPos= str.indexOf('x');
 int yPos= str.indexOf('y');
xyBalance("yaaxbby") → true      false      X         
xPos is the index of this x
yPos is the index of this y
xyBalance("xaxxbbyx") → false      true      X      
xPos is the index of this x
yPos is the index of this y  
xyBalance("bbb") → true      false      X      
xPos is -1
yPos is -1
xyBalance("y") → true      false      X      
xPos is -1    
yPos is the index of this y
xyBalance("") → true      false      X         
xPos is -1
yPos is -1
xyBalance("yxyxyxyxy") → true      false      X      
xPos is the index of this x
yPos is the index of this y
Avatar of gudii9

ASKER

public boolean xyBalance(String str) { 
  

 
 
for(int i=0;i<str.length();i++){
 int xPos= str.lastIndexOf('x');
 int yPos= str.lastIndexOf('y');
 int len=str.length();
 

 if(xPos>=0&&yPos>=0&&(yPos>xPos)){
 return true;
 }

}

return false;

}

Open in new window


above failing few edge cases
Expected	Run		
xyBalance("aaxbby") → true	true	OK	    
xyBalance("aaxbb") → false	false	OK	    
xyBalance("yaaxbb") → false	false	OK	    
xyBalance("yaaxbby") → true	true	OK	    
xyBalance("xaxxbby") → true	true	OK	    
xyBalance("xaxxbbyx") → false	false	OK	    
xyBalance("xxbxy") → true	true	OK	    
xyBalance("xxbx") → false	false	OK	    
xyBalance("bbb") → true	false	X	    
xyBalance("bxbb") → false	false	OK	    
xyBalance("bxyb") → true	true	OK	    
xyBalance("xy") → true	true	OK	    
xyBalance("y") → true	false	X	    
xyBalance("x") → false	false	OK	    
xyBalance("") → true	false	X	    
xyBalance("yxyxyxyx") → false	false	OK	    
xyBalance("yxyxyxyxy") → true	true	OK	    
xyBalance("12xabxxydxyxyzz") → true	true	OK	    
other tests
OK	    
Correct for more than half the tests

Your progress graph for this problem

Open in new window

Avatar of gudii9

ASKER

xyBalance("bbb") → true      false      X

xyBalance("y") → true      false      X
xyBalance("") → true      false      X

how above true
for all the 'x' chars in the string, there exists a 'y' char somewhere later in the string.
Avatar of gudii9

ASKER

but above cases there are no x chars and challenge does not talk about this scenario??
Avatar of gudii9

ASKER

We'll say that a String is xy-balanced if for all the 'x' chars in the string, there exists a 'y' char somewhere later in the string. So "xxy" is balanced, but "xyx" is not. One 'y' can balance multiple 'x's. Return true if the given string is xy-balanced. 

Open in new window


so if x itself is not there then it is always true no matter y there or not which is obviously irrelevant right??
Yes, if x is not there, it is always true.
Avatar of gudii9

ASKER

public boolean xyBalance(String str) { 
  

 
 
for(int i=0;i<str.length();i++){
 int xPos= str.lastIndexOf('x');
 int yPos= str.lastIndexOf('y');
 int len=str.length();
 

 if((xPos>=0&&yPos>=0&&(yPos>xPos))||(!str.contains("x")) || str.length()==0 ){
 return true;
 }

}

return false;

}

Open in new window


why above failing one as below?

Expected      Run            
xyBalance("aaxbby") → true      true      OK         
xyBalance("aaxbb") → false      false      OK         
xyBalance("yaaxbb") → false      false      OK         
xyBalance("yaaxbby") → true      true      OK         
xyBalance("xaxxbby") → true      true      OK         
xyBalance("xaxxbbyx") → false      false      OK         
xyBalance("xxbxy") → true      true      OK         
xyBalance("xxbx") → false      false      OK         
xyBalance("bbb") → true      true      OK         
xyBalance("bxbb") → false      false      OK         
xyBalance("bxyb") → true      true      OK         
xyBalance("xy") → true      true      OK         
xyBalance("y") → true      true      OK         
xyBalance("x") → false      false      OK         
xyBalance("") → true      false      X         
xyBalance("yxyxyxyx") → false      false      OK         
xyBalance("yxyxyxyxy") → true      true      OK         
xyBalance("12xabxxydxyxyzz") → true      true      OK         
other tests
OK         
Correct for more than half the tests
Avatar of gudii9

ASKER

ok i have to say <= instead of <
public boolean xyBalance(String str) {
 

 
 
for(int i=0;i<=str.length();i++){
 int xPos= str.lastIndexOf('x');
 int yPos= str.lastIndexOf('y');
 int len=str.length();
 

 if((xPos>=0&&yPos>=0&&(yPos>xPos))||(!str.contains("x")) || str.length()==0  ){
 return true;
 }

}

return false;

}

which oassed all tests
Expected      Run            
xyBalance("aaxbby") → true      true      OK         
xyBalance("aaxbb") → false      false      OK         
xyBalance("yaaxbb") → false      false      OK         
xyBalance("yaaxbby") → true      true      OK         
xyBalance("xaxxbby") → true      true      OK         
xyBalance("xaxxbbyx") → false      false      OK         
xyBalance("xxbxy") → true      true      OK         
xyBalance("xxbx") → false      false      OK         
xyBalance("bbb") → true      true      OK         
xyBalance("bxbb") → false      false      OK         
xyBalance("bxyb") → true      true      OK         
xyBalance("xy") → true      true      OK         
xyBalance("y") → true      true      OK         
xyBalance("x") → false      false      OK         
xyBalance("") → true      true      OK         
xyBalance("yxyxyxyx") → false      false      OK         
xyBalance("yxyxyxyxy") → true      true      OK         
xyBalance("12xabxxydxyxyzz") → true      true      OK         
other tests
OK         

public class XyBalanace {
	public static void main(String[] args) {
		System.out.println("Values is--->" + xyBalance(""));
		String str="";
		System.out.println("Values is--->" + str.length());
	}

	public static boolean xyBalance(String str) {

		for (int i = 0; i <= str.length(); i++) {
			int xPos = str.lastIndexOf('x');
			int yPos = str.lastIndexOf('y');
			int len = str.length();

if ((xPos >= 0 && yPos >= 0 && (yPos > xPos)) || (!str.contains("x")) || str.length() == 0) {
				return true;
			}

		}

		return false;

	}
}

Open in new window


output
Values is--->true
Values is--->0
Avatar of gudii9

ASKER

but my approach is bit rough and lengthy loooks like
There is no need for the loop here.
Avatar of gudii9

ASKER

public boolean xyBalance(String str) {
 

 
 
//for(int i=0;i<=str.length();i++){
 int xPos= str.lastIndexOf('x');
 int yPos= str.lastIndexOf('y');
 int len=str.length();
 

 if((xPos>=0&&yPos>=0&&(yPos>xPos))||(!str.contains("x")) || str.length()==0  ){
 return true;
 }

//}

return false;

}

i see without loop also i passed all tests?
when to decide to put loop when not?
A loop can be used to apply the same operation on different operands.
When the operands are always the same, the loop is probably not useful.
lastIndexOf, length(), contains, >=, >, &&, ||, !, ==
were all operations in the loop with operands that did not change, so they can be taken out of the loop

all together
{
			int xPos = str.lastIndexOf('x');
			int yPos = str.lastIndexOf('y');
			int len = str.length();

if ((xPos >= 0 && yPos >= 0 && (yPos > xPos)) || (!str.contains("x")) || str.length() == 0) {
				return true;
			}
}

Open in new window

can be considered an operation
(xPos >= 0 && yPos >= 0 && (yPos > xPos)) || (!str.contains("x")) || str.length() == 0
could also have been simplified
Avatar of gudii9

ASKER

(xPos >= 0 && yPos >= 0 && (yPos > xPos)) || (!str.contains("x")) || str.length() == 0
could also have been simplified

just to be 100% clear on below
lastIndexOf, length(), contains, >=, >, &&, ||, !, ==
were all operations in the loop with operands that did not change, so they can be taken out of the loop

all together
{
                  int xPos = str.lastIndexOf('x');
                  int yPos = str.lastIndexOf('y');
                  int len = str.length();

if ((xPos >= 0 && yPos >= 0 && (yPos > xPos)) || (!str.contains("x")) || str.length() == 0) {
                        return true;
                  }
}

                                         
1:
2:
3:
4:
5:
6:
7:
8:
9:
Select all
Open in new window
can be considered an operation

which one is the loop(for loop right which i commented) which one are operands(the one on which we are acting in the loop namely int i??)

please advise
Since you have an if then else scenario, there is no need for a loop. Why not simply -
return (!str.contains("X") || str.isEmpty()) ? true : str.lastIndexOf("Y") >= str.lastIndexOf("X");
str.lastIndexOf('x');
lastIndexOf is an operator, with operands str and 'x'

xPos >= 0
>= is an operator, with operands xPos and 0

xPos >= 0 && yPos >= 0
&& is an operator, with operands xPos >= 0 and yPos >= 0

str.contains("x")
contains is an operator, with operands str and "x"

!str.contains("x")
! is an operator, with operand str.contains("x")

str.length()
length is an operator, with operand str

str.length() == 0
== is an operator, with operands str.length() and 0
(Which, by the way, is completely superfluous here. Do you see why?)

xyBalance("aaxbby")
xyBalance is an operator, with operand "aaxbby"


{
                  int xPos = str.lastIndexOf('x');
                  int yPos = str.lastIndexOf('y');
                  int len = str.length();

if ((xPos >= 0 && yPos >= 0 && (yPos > xPos)) || (!str.contains("x")) || str.length() == 0) {
                        return true;
                  }
}
is an operator, with operands str, 'x', 'y', 0, "x", true
return (!str.contains("X") || str.isEmpty()) ? true : str.lastIndexOf("Y") >= str.lastIndexOf("X");
could have been simply
return str.lastIndexOf("y") >= str.lastIndexOf("x");
DOH! I think gudii9 has me thinking things are more complex than they need be. :-)
(!str.contains("X") || str.isEmpty()) == (!str.contains("X"))
Avatar of gudii9

ASKER

str.length() == 0
== is an operator, with operands str.length() and 0
(Which, by the way, is completely superfluous here. Do you see why?)
no . can you please elaborate?

{
                  int xPos = str.lastIndexOf('x');
                  int yPos = str.lastIndexOf('y');
                  int len = str.length();

if ((xPos >= 0 && yPos >= 0 && (yPos > xPos)) || (!str.contains("x")) || str.length() == 0) {
                        return true;
                  }
}
is an operator, with operands str, 'x', 'y', 0, "x", true
i do not see operator above? what is operator name?
also i do not see why xPos and yPos is not operands?
x and y are highlighted ones right?
Avatar of gudii9

ASKER

return (!str.contains("X") || str.isEmpty()) ? true : str.lastIndexOf("Y") >= str.lastIndexOf("X");
could have been simply
return str.lastIndexOf("y") >= str.lastIndexOf("x");

how?please advise
As mentioned, (!str.contains("X") || str.isEmpty()) == (!str.contains("X")) so isEmpty is unnecessary
But even contains is unnecessary, since lastIndexOf returns -1 if the character does not occur.
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#lastIndexOf(int)
Avatar of gudii9

ASKER

public boolean xyBalance(String str) {
//for(int i=0;i<=str.length();i++){


// int xPos= str.lastIndexOf('x');
 //int yPos= str.lastIndexOf('y');
// int len=str.length();
// if((xPos>=0&&yPos>=0&&(yPos>xPos))||(!str.contains("x")) || str.length()==0  ){
// return true;
// }
//}
//return false;


return str.lastIndexOf("y") >= str.lastIndexOf("x");
}

above passed all
lastIndexOf
public int lastIndexOf(int ch,
              int fromIndex)
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index. For values of ch in the range from 0 to 0xFFFF (inclusive), the index returned is the largest value k such that:

can i write this challenge solution using above method instead searching backwards?
what is operator name?
I don't know if it has a name.   If you wrote it, I guess you can get to name it.
Or maybe its name is xyBalance, but in that case, I would consider str to be the only operand, with 'x', 'y', 0, "x", true being unchangeable parts of the operator

I might think of xPos as an operand to
    xPos >= 0
but not as an operand to
    int xPos = str.lastIndexOf('x');
    xPos >= 0
since in the latter case it would be internal to the combined operation of the two statements together.

If you prefer to use the word "operation" only when referring to elementary operations like >=
and not to combined operations like  (!str.contains("X") || str.isEmpty()),
that would also be an acceptable usage, but then I would want to find a more general term to say
"A loop can be used to apply the same operation on different operands."
can i write this challenge solution using above method instead searching backwards?
Above method uses lastIndexOf, which is searching backwards.
But since lastIndexOf is doing it, your code does not have to.

It might also be done searching forwards instead of backwards, but that seems less natural for this problem.
Avatar of gudii9

ASKER

Above method uses lastIndexOf, which is searching backwards.
But since lastIndexOf is doing it, your code does not have to.

It might also be done searching forwards instead of backwards, but that seems less natural for this problem.

how to write without failing any test cases?
Are you failing any test cases?
Avatar of gudii9

ASKER

return !str.matches(".*x[^y]*");

what is meaing of above code and how to test it in regex101 site with step by step screenshot procedure if possible please??
Avatar of gudii9

ASKER

i tried as attached but no success.

please advise
regex101.png
Avatar of gudii9

ASKER

https://regex101.com/r/eF4wT3/2

i see you got false.

can you please explain each section that we need to enter in regex101 site to get the output?
i see substitution section has false? is substitution same as output section?
Avatar of gudii9

ASKER

https://regex101.com/r/eF4wT3/2


i see you got false.

can you please explain each section that we need to enter in regex101 site to get the output?
i see substitution section has false? is substitution same as output section?

according to challenge we should get true right not false as you got in above link?
how to get true?
Avatar of gudii9

ASKER


[^y]* match a single character not present in the list below

which list regex101 mean meant when they mention as above in their site?
Avatar of gudii9

ASKER

aaxbby    
aaxbb unbalanced
yaaxbb unbalanced
yaaxbby        
xaxxbby
xaxxbbyx unbalanced
xxbxy
bbb
bxbb unbalanced
bxyb
x unbalanced
y

yxyxyxyx unbalanced
yxyxyxyxy
other tests

how to print balanced as well similar to unbalanced as below



aaxbby    balanced
aaxbb unbalanced
yaaxbb unbalanced
yaaxbby       balanced  
xaxxbby balanced
xaxxbbyx unbalanced
xxbxy  balanced
bbb  balanced
bxbb unbalanced
bxyb  balanced
x unbalanced
y

yxyxyxyx unbalanced
yxyxyxyxy balanced
other tests
I substituted the string "false" instead of "true" because the java code would have !negated the result of the matches call.
That may have been a poor choice if it caused confusion.
I tried to be more clear by substituting "$0 unbalanced"
We might match the balanced lines instead of the unbalanced lines with a (?!negative lookahead) regular expression
https://regex101.com/r/eF4wT3/5
but that adds complication that gets us further afield of the java code we were trying to elucidate.

To generate either "balanced" or "unbalanced" with a single substitution would require a substitution that conditionally depended on what was matched, which is not possible within the regex101.com substitution syntax.
Avatar of gudii9

ASKER

To generate either "balanced" or "unbalanced" with a single substitution would require a substitution that conditionally depended on what was matched, which is not possible within the regex101.com substitution syntax.
ok
I substituted the string "false" instead of "true" because the java code would have !negated the result of the matches call.
That may have been a poor choice if it caused confusion.
I tried to be more clear by substituting "$0 unbalanced"
unbalanced is more clear approach to me
We might match the balanced lines instead of the unbalanced lines with a (?!negative lookahead) regular expression

not clear what you meant by ?!negative lookahead
please advise
not clear what you meant by ?!negative lookahead
That's why I didn't want to use it in the first illustration, and showed a regexp that matched xyunbalanced lines instead of xybalanced liines.

However, Java regular expression constructs are all listed here: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Most of them seem similar enough to the notation used by regex101.com that the latter can be used for illustrative purposes, but the more subtle features you use, the more chances there are for divergence between implementations.
Avatar of gudii9

ASKER


That's why I didn't want to use it in the first illustration, and showed a regexp that matched xyunbalanced lines instead of xybalanced liines.

which is first which is second. what you mean by did not want to use?

which one you used in second illustration and where you used it?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial