Solved

Multiple delete tag in html regex

Posted on 2013-01-09
7
926 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

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…
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
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…

777 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