I am porting some functionality from a C++ application to java. This involves reading non-modifiable data files that contain regular expressions.
A lot of the data files contain regular expressions that look similar to the following:
(?<=id="VIEWSTATE".*?value=").*?(?=")
These regular expressions produce the following error:
"Look-behind group does not have an obvious maximum length near index XX"
In C++ the engine being used supported these expressions. Is there another form of regexp that can produce the same result that can be generated using expressions like my example as input?
As far as I know, only .NET and JGSoft, among all the current regex flavors, support unbounded quantifiers in lookbehind expressions. If you can't change the regex, you can't do what you want in Java.
But lookbehind is the wrong way to do that job in the first place. It would have been much easier, as well as more efficient, to use a capturing group:
id="VIEWSTATE".*?value="([^"]*)"
...then you retrieve the value from group #1. Are you sure you can't change the regexes?