Solved

Multiple delete tag in html regex

Posted on 2013-01-09
7
936 Views
Last Modified: 2013-01-09
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
Comment
Question by:localseo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 38760781
$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
 

Author Comment

by:localseo
ID: 38760801
But what do I use for find field and then replace field, in program like bbedit?

Thanks
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 38760826
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
Independent Software Vendors: 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!

 
LVL 31

Expert Comment

by:Marco Gasi
ID: 38760843
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
 

Author Comment

by:localseo
ID: 38760918
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
 

Author Closing Comment

by:localseo
ID: 38761078
Managed to get it to work,

thanks
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 38761819
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA Test For Valid Number Format 6 76
Parse CSS value with RegEx 2 91
Regular expressions Exclude patter 3 46
Need some help with regex 3 53
by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question