By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

help / php regular expressions

P: n/a
$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

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Pooxeur wrote:
$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 ?


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!
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.