Jump to content

preg match all help


Kovo

Recommended Posts

Hello, Ive got the pattern below:

preg_match_all('`\[(.+?)=?([a-zA-Z0-9_:\/=&\.]*?)\](.+?)\[/\1\]`', $string, $matches)

Its part of a bbcode parser. My problem is the pattern in between the tags "(.+?)" does not match new lines so if I have a string like so: Hello \n World!The parser will break or skip it.How do I go about converting this pattern to accept new lines?Thank you!

Link to comment
Share on other sites

Use the multiline modifier or dotall modifier:http://www.php.net/manual/en/reference.pcr...n.modifiers.php
Where would I put it?
preg_match_all('`\[(.+?)=?([a-zA-Z0-9_:\/=&\.]*?)\](.+?)\[/\1\]`s', $string, $matches)

or

preg_match_all('`\[(.+?)=?([a-zA-Z0-9_:\/=&\.]*?)\](.+?)\[/\1\]s`', $string, $matches)

Thanks!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...