Java regex torment -


i created following conditional regex seems work @ http://gskinner.com/regexr/ doesn't compile in java.

the regex follows :

x: (\d+). y: (\d+)(?(?=:inherit=(true|false))) 

and supposed pull x, y value , (if exists) value followed :inherit=

e.g

x: 192131, y: 1923123 (matches 192131, 1923123)  x: 192131, y: 1923123:inherit=true (matches 192131, 1923123, true)  x: 192131, y: 1923123:inherit=false (matches 192131, 1923123, false) 

in java error:

unknown inline modifier near index 20 x: (\d+). y: (\d+)(?(?=:inherit=(true|false)))  

with index 20 being second parenthesis in (?(?

can me right in java, , maybe explain why website tester processes it.

thanks!

(?( not valid syntax.

use:

x:\s(\d+),\sy:\s(\d+)(?::inherit=(true|false))? 

you need escape \.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -