0

This regular expression in C# is giving me error in java:

"<input type="hidden" name="GALX" value="(?<galx>[a-zA-Z0-9_]+)">"  

Error:

Look-behind group does not have an obvious maximum length near index 60
<input type="hidden" name="GALX" value="(?<galx>[a-zA-Z0-9_]+)">

What would be the equivalent expression in Java?

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Uzair Farooq
  • 917
  • 3
  • 15
  • 25
  • First of all you should not use regex to parse HTML, see here: http://stackoverflow.com/questions/590747/using-regular-expressions-to-parse-html-why-not to see why. Secondly, what error are you getting? And thirdly, Java, by default, seems to add the ^ and $ anchors to your regex, so you will have to cater for that as well. – npinti Jan 02 '12 at 10:02

1 Answers1

0

This i'm guessing. I changed ' to " and escaped any "

"<input type=\"hidden\" name=\"GALX\" value=\"(?<galx>[a-zA-Z0-9_]+)\">" 

Edit :: And for the named grouping of "galx" only java 7 supports this

Regex Named Groups in Java

Community
  • 1
  • 1
AlanFoster
  • 8,156
  • 5
  • 35
  • 52