On 12 July 2013 09:57, Niraj <[email protected]> wrote: > Can someone please help me in regular expression > > > test.FilterPanel.viewId = \"136e6c9e-689a-4d24-a3bc-2ace008bee2f\"
> *i want to extract **136e6c9e-689a-4d24-a3bc-2ace008bee2f **from this. * > > *Please let me know what should be correct reg ex * > * > * > *i tried **viewId = \"(.*)\ But got the > error org.apache.oro.text.MalformedCachePatternException: Invalid > expression: viewId = \"(.*)\* > *Trailing \ in expression.* It's quite difficult reading your posting because of all the extra * characters that are scattered about. But assuming you start with test.FilterPanel.viewId = \"136e6c9e-689a-4d24-a3bc-2ace008bee2f\" and want to extract 136e6c9e-689a-4d24-a3bc-2ace008bee2f Then the way to do it is to take your input, and escape any meta-characters: In this case, the \ is the only special char, so it becomes: test.FilterPanel.viewId = \\"136e6c9e-689a-4d24-a3bc-2ace008bee2f\\" Now put () around the part you want to extract: test.FilterPanel.viewId = \\"(136e6c9e-689a-4d24-a3bc-2ace008bee2f)\\" Of course this will only extra the exact id, so now you need to make the id dynamic. In this case, the Id seems to consist of lower-case hex and - only, which is matched by [-\da-f]+ In the above, the - must come first, otherwise it is treated as a range, as in a-f. The \d means digit; you could use 1-9 instead So the final expression becomes: test.FilterPanel.viewId = \\"([-\da-f]+)\\" If the Id could include other characters, you could also use the fact that it is terminated by \, so you could replace [-\da-f]+ by [^\\]+ which means anything except \, repeated any number of times. Try this process out in the Tree View Listener regex pane. > * > *Thanks,* > *Niraj* > * > * > * > * > * > * --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
