Advertisement

06.24.2008 at 10:38AM PDT, ID: 23511849
[x]
Attachment Details

preg_replace - need help plz

Asked by psimation in Regular Expressions

Hi

I'm using PHP's preg_replace function that can handle regular expressions.

I'm trying to remove a <a href="xxx.com">click here<a> from a bunch of HTML, but the link itself contains a random number, and there is some text directly after the </a> that I'm also trying to remove.

So, for example:

sample text:

asdsa sad asd sada hkjas <a href="xxx.com?a=32432432432>click here</a> to follow link. asdsadsad asda das dsad asd <a href="xxx.com">click some more</a> sdasadasd ad adsa sad adasd dsad ada das


I want to match and remove ( replace with "" ) >> <a href="xxx.com?a=32432432432>click here</a> to follow link.

where the "32432432432" is random, while leaving other <a> tags untouched - hence the attempt to match as much as possible with only the number as a "wildcard"...

Start Free Trial
[+][-]06.24.2008 at 10:44AM PDT, ID: 21858297

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Regular Expressions
Sign Up Now!
Solution Provided By: ddrudik
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.24.2008 at 10:46AM PDT, ID: 21858313

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2008 at 10:13AM PDT, ID: 21867813

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.25.2008 at 10:21AM PDT, ID: 21867887

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 11:30AM PDT, ID: 21919231

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628