Thursday, 15 May 2014

php - Always get "Unknown modifier" when using a RegEx -



php - Always get "Unknown modifier" when using a RegEx -

i'm trying utilize sec single line regex preg_match() page: http://daringfireball.net/2010/07/improved_regex_for_matching_urls

(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))

always get:

unknown modifier '\' in ...

can tell me how utilize regex correctly preg_match() or regex incorrect?

you need surround regex delimiters (in case, suggest ~ because it's not beingness used anywhere in regex) , utilize mode modifiers (~i) instead of inline modifiers ((?i)):

~\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))~i

php regex preg-match

No comments:

Post a Comment