[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 981
  • Last Modified:

Multiple delete tag in html regex

Hello,

I have  a program that inserts tags into html like this:

<img src="msggen/LwedmAsTMPwwCy4ECXv44AMSG5MSG5.png-msgpwidth=320&msgpheight=-1&msgwebwidth=320.png" tppabs="http://url.com/msggen/LwedmAsTMPwwCy4ECXv44AMSG5MSG5.png?msgpwidth=320&msgpheight=-1&msgwebwidth=320" />

I need to delete all the tppabs="http://url.com/msggen/LwedmAsTMPwwCy4ECXv44AMSG5MSG5.png?msgpwidth=320&msgpheight=-1&msgwebwidth=320"

what is the regex I can use for a find and replace program.

Thank you

Fernando
0
localseo
Asked:
localseo
  • 4
  • 3
1 Solution
 
Marco GasiFreelancerCommented:
$htm = "<img src="msggen/LwedmAsTMPwwCy4ECXv44AMSG5MSG5.png-msgpwidth=320&msgpheight=-1&msgwebwidth=320.png" tppabs="http://url.com/msggen/LwedmAsTMPwwCy4ECXv44AMSG5MSG5.png?msgpwidth=320&msgpheight=-1&msgwebwidth=320" />";
$result = preg_replace('%tppabs.*(?=/>)%im', '', $htm);

Cheers
0
 
localseoAuthor Commented:
But what do I use for find field and then replace field, in program like bbedit?

Thanks
0
 
Marco GasiFreelancerCommented:
I don't know bbedit. Using notepad++ you only need to open Replace panel (menu Search->Replace) check Regular Expression radio button, type in the reg ex, the replacement value and click Replace All.
 Maybe bbedit has something similar...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Marco GasiFreelancerCommented:
Perhaps this is useful: http://www.journey-of-flight.com/bh_bbedit/how-to/useful_regex/index.php (see paragraph identified by 'image 7')
0
 
localseoAuthor Commented:
thanks, i downloaded notepad++

this should be the regex to use in find?

%tppabs.*(?=/>)%im  still get 0 results though

Thanks
Screen-Shot-2013-01-09-at-21.48..png
0
 
localseoAuthor Commented:
Managed to get it to work,

thanks
0
 
Marco GasiFreelancerCommented:
I'm sorry if I didn't reply to you but I have gone to sleep. Thanks for point. What were wrong the first time? Seeing the screenshot I don't see anything wrong...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now