FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Extracting multiple matches from a string using preg_replace
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Extracting multiple matches from a string using preg_replace [message #178586 is a reply to message #178583] Mon, 09 July 2012 18:58 Go to previous messageGo to previous message
jwcarlton is currently offline  jwcarlton
Messages: 76
Registered: December 2010
Karma:
Member
On Monday, July 9, 2012 8:44:06 AM UTC-4, Captain Paralytic wrote:
> Well I'm very confused by all this. First of all, why are you using
> preg_replace to extract the vidid? I would have thought that a job
> better suited to preg_match.

Probably just a lack of knowledge on my part. I thought that preg_match was used to find if the regex was true or false, and then preg_replace would be used to replace whatever.

From Peter's reply, I don't think that either of them are the right command.. But for the sake of my own learning, how would I have modified my script (catching only one) to use preg_match instead of preg_replace?

And, if preg_replace works, then what's the advantage? Speed?


> Next, in your string assigned to $this_comment, the first vidid is
> different to the other 2, so why are you expecting $this_id to match
> all of them?

No, that was the point; they're not going to match, so I need to modify the script to replace ALL of the existing links with the ID that's in that link.

That's why I turned to you guys. My only thought was to put the script in a function, then use a while() loop to keep running the function until there were no more links. I couldn't get it to work, though, and I didn't like the idea of using a loop on it, anyway, so I thought you guys might have a better suggestion.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Invitacion a INFOSOFT 2012 [PUCP]
Next Topic: PHP does not flush output on IIS7 ..
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 03:46:29 GMT 2024

Total time taken to generate the page: 0.04132 seconds