Javasript replace help

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Javasript replace help

Post 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.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post 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(":", "_")
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Is there a reason this is not being done in PHP?
Post Reply