Posted: Wed Jan 14, 2004 7:04 pm
The multi-line mode modifier does cause some confusion. The multi-line modifer only affects the ^ and $ meta-characters.
This spans back to regex originally being a command line tool so in theory you could only apply a regex to a single line. As time moved on the multi-line modifier was intoduced to cope with applying regex to entire documents. So by default ^ now means line starts with and $ means line ends with. By applying the multi-line modifier, ^ becomes document (or multi-line string) starts with and $ becomes document (or multi-line string) ends with.
What you require is the 'dot all' modifier. Again as regex was a commandline tool originally the . meta-character matched any character in a single line so it stopped if it found a new line character. By default the . meta-character matches anything except new line but by asserting the 'dot all' modifier the . meta-character becomes 'match any character including new lines.
Also your multi-line modifier is in the wrong place. Your regex should look like something similar to below...
Not sure if you were using match or match_all
This spans back to regex originally being a command line tool so in theory you could only apply a regex to a single line. As time moved on the multi-line modifier was intoduced to cope with applying regex to entire documents. So by default ^ now means line starts with and $ means line ends with. By applying the multi-line modifier, ^ becomes document (or multi-line string) starts with and $ becomes document (or multi-line string) ends with.
What you require is the 'dot all' modifier. Again as regex was a commandline tool originally the . meta-character matched any character in a single line so it stopped if it found a new line character. By default the . meta-character matches anything except new line but by asserting the 'dot all' modifier the . meta-character becomes 'match any character including new lines.
Also your multi-line modifier is in the wrong place. Your regex should look like something similar to below...
Code: Select all
preg_match_all('/<!-- NEWEST ANNOUNCED.*<!-- AFFILIATE/s', $content, $match))