Java Regex Engine question - Conditional Statements?
807591Jun 4 2008 — edited Jun 4 2008Hi guys
I am having difficulty writing a conditional regular expression using Java regex implementation.
I have read that the java regex engine does not implement the conditional statement that is present in Perls regex engine.
for example in Perl you can have (?(?=regex)then|else)
The application can recieve a string in anyone of these 4 formats and a single regular expression is needed to match MyMatch in each instance.
1. Blade=0-3,MyMatch=1
2. Blade=0-3,MyMatch.attribute=1
3. MyMatch=1
4. MyMatch.attribute=1
I can do this with the following regular expression using the Perl engine.
(?(.+,).+,([^\.]*).*=.+|([^\.]*).*=.+)
But I am completely stumped as to how I can do it with Java as the conditional statement does not seem to be implemented.
Any help greatly appreciated.
Steve