Reputation: 887
I need to use preg_match to check if a line is ending with /> or / >
I have created a function, that contains the followling line
if (!preg_match('\/>$', $str)) {
But it do not work, as it comes with this error
Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash
How can I make it work?
Upvotes: 0
Views: 1936
Reputation: 27913
Added an optional space between \ and >.
if (!preg_match('|\/ ?>$|', $str)) {
Upvotes: 2
Reputation: 222108
http://php.net/manual/en/regexp.reference.delimiters.php
When using the PCRE functions, it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.
You can use |
for example
if (!preg_match('|\/>$|', $str)) {
Upvotes: 3