Link to home
Start Free TrialLog in
Avatar of rwhubbard996
rwhubbard996Flag for United States of America

asked on

Find & Replace using regular expressions

I'll admit regular expressions are an egnigma for me.

I'm trying to find every thing starting with .php in tage like this:

<a href="<?=$search_page?>.php?ser=engr1">
<a href="<?=$search_page?>.php?ser=engr2">
<a href="<?=$search_page?>.php?ser=dia_ring">

And dump it so they all look like this:

<a href="<?=$search_page?>">

Any suggestions?
Thanks,
Roger
ASKER CERTIFIED SOLUTION
Avatar of Filips Houbrechts
Filips Houbrechts
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rwhubbard996

ASKER

This is very helpful.  I'm purchasing regexbuddy.  Your expression works perfect!
Glad you like the tool. Have fun and thanks for the A.
Already used it!
$file_name = preg_replace("/-+/","-",$file_name);

to replace multiple -'s  of any number 1 and up with just 1
or

$file_name = preg_replace("/^-{2,}/","-",$file_name);

replace only when 2 or more - 's
Avatar of pbhj
pbhj

Don't forget that there are free online resources like http://www.quanetic.com/regex.php. As well as gui tools like Kregexpeditor (http://www.blackie.dk/KDE/KRegExpEditor/)