Connecting Tech Pros Worldwide Forums | Help | Site Map

help / php regular expressions

Pooxeur
Guest
 
Posts: n/a
#1: Jul 17 '05
$string = "a frist string [[a second string]]";

I want to get in one line of code (using ereg)

$string2 = "a second string";

what is the good regexp ?
thanks

Pooxeur,
http://pooxi.free.fr/?oid=nwsclp




Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: help / php regular expressions


Pooxeur wrote:[color=blue]
> $string = "a frist string [[a second string]]";
>
> I want to get in one line of code (using ereg)
>
> $string2 = "a second string";
>
> what is the good regexp ?[/color]

Don't know about ereg; using preg_*() is faster and more powerful.
See the manual @ http://www.php.net/pcre

<?php
echo preg_replace('/^.*\[\[(.*)\]\]$/', '\1', 'one [[two]]');
?>

This script outputs: two

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Closed Thread