user1935281
user1935281

Reputation:

regex modify backslash

How could I modify this regex:

preg_match_all('/\[startstring\](.*?)\[endstring\]/s', $input, $matches);

to look for @ instead of [startstring], and ; instead of [endstring]?

When I try this:

preg_match_all('/\@\(.*?)\=(.*?)\;\/s', $input, $matches);

it doesn't work. :( It says something like No ending delimiter '/' found in /home/content/76/7290476/html/newr.php on line 3.

Upvotes: 1

Views: 55

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191749

You escaped the final backslash for some reason. You're also escaping @ and ;, which is unnecessary:

#@(.*?)=(.*?);#s

You don't have to use the slash as a delimeter (above, I used #). Be careful about escaping characters that you shouldn't. I don't think you intended to escape that first paren either.

Upvotes: 2

Related Questions