Javascript Replace text in string

Posted by Tegan Snyder on Stack Overflow See other posts from Stack Overflow or by Tegan Snyder
Published on 2010-06-17T19:57:25Z Indexed on 2010/06/17 20:03 UTC
Read the original article Hit count: 200

Filed under:
|
|

I'm having some troubles getting regex to replace all occurances of a string within a string.

**What to replace:**
href="/newsroom

**Replace with this:**
href="http://intranet/newsroom

This isn't working:

str.replace(/href="/newsroom/g, 'href="http://intranet/newsroom"');

Any ideas?

Thanks, Tegan

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex