Monday, June 14, 2010

Smallest possible match

Regular expression smallest match.
I need one regular expression to extract all the opening tag, closing tag and all the strings in between opening and closing tag. eg:

Is this all there anything can be here, \n
[]+*403<>??!@#$%^&*()adsfadsf





By default the regular expression [\w|\W] would give the whole string above. To get the three pairs of open and close tag. You do [\w|\W]+?

Reference:
http://www.unagibay.com/DesktopDefault.aspx?tabindex=1&tabid=100&itemid=1826
http://www.regextester.com/

No comments:

Post a Comment