Page 1 of 1

Javasript replace help

Posted: Tue Jan 30, 2007 3:09 am
by Shendemiar
I'd like to replace data of format (1:2:3) with a text like a.b.c/d.php?e=1_2_3 on forums webpage.

The regexp used could be something like this:
(?<LOCATION>(?<=\()\d+:\d+:\d+(?=\)))

Then the :'s needs to be replaced with _'s and the url prefix and suffix added. and the original match replaced with this new sting.

I have no knowledge of javascrip and i find it hard to code. If its trivial for someone to do this rather simple procedure id appriciate any help.

Posted: Tue Jan 30, 2007 5:02 am
by Shendemiar
In my pseudo-code it would be something like this:

Pseudocode:

Code: Select all

For each match do {  
  String = whole document
  String.replace("/(?<LOCATION>(?<=\()\d+:\d+:\d+(?=\)))/", "[url]<LOCATION>[/url]").replace(":", "_")
}

Posted: Tue Jan 30, 2007 8:00 am
by feyd
Is there a reason this is not being done in PHP?