Jump to content

preg_replace on multiple matches


axiom82

Recommended Posts

I'm trying to replace the Microsoft Office Link Code found in the source code of Word docs.  You may have seen this before:

 

$msword_text = ' HYPERLINK "http://www.website.com" http://www.website.com';

 

Here is what I'd like to see:

<a href="http://www.website.com">http://www.website.com</a>

 

Here is what I've tried:

$msword_text = preg_replace('/ HYPERLINK "(.+)" (.+)/', '<a href="\\1">\\2</a>', $msword_text);

 

 

It doesn't work and I've been banging my head on this one for hours.  Please help! :)

Link to comment
https://forums.phpfreaks.com/topic/186230-preg_replace-on-multiple-matches/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.