Does anyone know what is wrong with this regex? It works fine on sites like RegexPal and RegExr, but in PHP it gives me this warning and no results:
Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash
Here's my code:
preg_match('name="dsh" id="dsh" value="(.*?)"', 'name="dsh" id="dsh" value="123"', $matches);
You have no delimiter. Enclose the pattern in /
preg_match('/name="dsh" id="dsh" value="(.*?)"/', 'name="dsh" id="dsh" value="123"', $matches);
For patterns that include /
on their own, it is advisable to use a different delimiter like ~
or #
to avoid escaping:
// Delimited with # instead of /
preg_match('#name="dsh" id="dsh" value="(.*?)"#', 'name="dsh" id="dsh" value="123"', $matches);
You need delimiters:
preg_match('/name="dsh" id="dsh" value="(.*?)"/', 'name="dsh" id="dsh" value="123"', $matches);
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