Link to home
Start Free TrialLog in
Avatar of pillmill
pillmill

asked on

convert sed to preg_match?

How do I convert an sed expression into a php preg_match search?

The sed search is:   sed -n "s/.*name='\([^']*\).*/\1/p"

I need to do the equivalent with php using preg_match or a similar function.
Avatar of larsrohr
larsrohr
Flag of United States of America image

preg_replace may suit your needs.  You won't need to escape the grouping parentheses.
$mystring = "something name='pillmill' etc";
$newstring = preg_replace("/.*name='([^']*).*/", "$1", $mystring);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America 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