Match username - /^[a-zA-Z0-9_]{3,16}$/ Matching an XHTML/XML tag - {]*>(.*?)} Matching an XHTML/XML tag with a certain attribute value (e.g. class or tag) - {]*attribute\\s*=\\s*(["'])value\\\\1[^>]*>(.*?)} Matching a URL - (a very long one... refer to article...)
You have a string “BEFOREAFTER”. If this string has a ‘x’ in it, you want to capture everything before the ‘x’, else you want to capture the whole string. So, ”BEFOREAFTER” gives “BEFOREAFTER” ”BEFORExAFTER” gives “BEFORE” http://octodecillion.com[..]apture-with-optional-delimeter/#solution