regex - I'm looking to extract values from matched pattern in Java -
i'm using regex:
([\w\s]+)(=|!=)([\w\s]+)( (or|and) ([\w\s]+)(=|!=)([\w\s]+))*
to match string such this: i= 2 or =3 , k!=4
when try extract values using m.group(index), get: (i, =, 2, **and k!=4**, and, k, ,!=, 4).
expected output: (i, =, 2, or, i, =, 3, and, k , !=, 4) how extract values correctly?
p.s. m.matches()
returns true.
you trying match regexp on expression...you might want use parser, because regexp (when have it) can't extended further..but parser can extended @ time
for example, consider using antlr (antlr: there simple example?)
Comments
Post a Comment