I have this regular expression:
([http://some.url.com/index.php?showtopic=\"]*)([0-9]+(?:\.[0-9]*)?)
its for extracting links to topics from forum
Now when i use it in my script
$url = "([http://some.url.com/index.php?showtopic=\"]*)([0-9]+(?:\.[0-9]*)?)";
preg_match_all spits: "Unknown modifier '('"
This is also the call to preg_match
preg_match_all($url, $str, $matches,PREG_OFFSET_CAPTURE,3);
Can anyone help me with this obviously stupid problem
You need to wrap your regular expression in delimiters. Any character that isn't a special PCRE metacharacter will do, so I'll use #:
$url = "#([http://some.url.com/index.php?showtopic=\"]*)([0-9]+(?:\.[0-9]*)?)#";
You can learn more about delimiters in the PHP manual section for PCRE delimiters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With