help with regular expressions [message #174320] |
Sat, 04 June 2011 16:55 |
Innerlab
Messages: 2 Registered: June 2011
Karma: 0
|
Junior Member |
|
|
Hello. I'm trying to parse pages from wikipedia. Although I'm not
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:
[url=_Name_of_URL_] Name_of_URL [/url]
So, with regex I must parse the above to construct links like:
<a href="http://URL">Name_of_URL</a>
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.
_______________________
Eduardo Gomez
|
|
|
Re: help with regular expressions [message #174321 is a reply to message #174320] |
Sat, 04 June 2011 17:01 |
Innerlab
Messages: 2 Registered: June 2011
Karma: 0
|
Junior Member |
|
|
Hello. On the previous post, I made an error:
> I have a PHP script that returns links within wikipedia pages as:
> [url=_Name_of_URL_] Name_of_URL [/url]
> So, with regex I must parse the above to construct links like:
> <a href="http://URL">Name_of_URL</a>
The last line should have read:
<a href="http://Name_of_URL">Name_of_URL</a>
My apologies...
_______________________
Eduardo Gomez
|
|
|
|
Re: help with regular expressions [message #174345 is a reply to message #174320] |
Mon, 06 June 2011 14:06 |
Nick Wedd
Messages: 1 Registered: June 2011
Karma: 0
|
Junior Member |
|
|
On 04/06/2011 17:55, Innerlab wrote:
> Hello. I'm trying to parse pages from wikipedia. Although I'm not
> 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:
>
> [url=_Name_of_URL_] Name_of_URL [/url]
>
> So, with regex I must parse the above to construct links like:
>
> <a href="http://URL">Name_of_URL</a>
>
> 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.
Can you give an actual example of a string that you might want to
process, and of what you want it converted to?
Nick
--
Nick Wedd
nick(at)maproom(dot)co(dot)uk
|
|
|