Forum Moderators: coopster

Message Too Old, No Replies

preg_match_all on multiple lines

         

turbohost

11:33 am on Dec 18, 2004 (gmt 0)

10+ Year Member



Hi Guys,

I'm running a script with a preg_match_all like :

preg_match_all('/blabla (.+?)\/(.+?)\//im',$blafiltered,$blais);

I use this to get text like bla1/bla2/bla3
The first preg_match works and I get the result bla1 and bla2. If I run the second preg_match below it doesn't work (I want to have all 3 bla's)

preg_match_all('/blabla (.+?)\/(.+?)\/(.+?)\//im',$blafiltered,$blais);

The only difference is that bla1 and bla2 are on the same line and bla3 is on another line. How can I fix my script?

Turbo

turbohost

3:03 pm on Dec 18, 2004 (gmt 0)

10+ Year Member



someone?

jatar_k

8:58 pm on Dec 18, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



<mod bump> for someone with better regex ;)

coopster

2:24 pm on Dec 19, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't have the time to show a recommendation or test right now, but I can point you in the right direction I believe...try the /s modifier [php.net].

preg_match_all('/blabla (.+?)\/(.+?)\//ims',$blafiltered,$blais);