Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- help with regular expressions
June 4, 2011, 4:55 pm
rate this thread
that good with PHP, such scripts are more available on the web than -
lets say- ASP/ VBscript.
I have a PHP script that returns links within wikipedia pages as:
[[ Name_of_URL ]]
So, with regex I must parse the above to construct links like:
I know the preg_replace( ) function is the one to use, but honestly, I
cannot figure out what regex I must use.
I'd appreciate any guidance on this matter.
Thanks in advance.
Re: help with regular expressions
It'll be easier if you catch the matches with preg_match and assemble
what you need out of that:
Note that square brackets will need to be escaped as those signify
character groups in a regex.
$regex = '/\[(.*?)\]/';
echo $matches; prints Name of URL