Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2006, 11:54 PM
Registered User
 
Join Date: Jun 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to skyler
Default Replace method don't work with [ ] /

I’m having problem with replace method, I can’t replace the char “[”, “]” and “/”. I tried with back slash, ascii, and didn’t worked. Look the example:

var tex = "[link href=”...”] Test [/link]";

tex = tex.replace(/[link href=/gi,'<a href=');
tex = tex.replace(/[/link]/gi,'</a>');

document.write(tex);

Someone have any idea?


 
Old December 30th, 2006, 10:04 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

[ and ] are reserved characters, used to delineate character sets such as [1-9] for digits except zero. You should be able to write:
Code:
/\[link\]/
--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Would this php cookies embedding method work? Puripong PHP How-To 0 November 8th, 2007 10:34 AM
Replace Method in JavaScript kwilliams Javascript How-To 2 April 3rd, 2007 12:50 PM
CompositeDataBoundControl's Render method not work bmains ASP.NET 2.0 Professional 0 January 12th, 2006 09:22 AM
Insert method doesnot work shoakat Classic ASP Databases 3 November 22nd, 2004 07:46 PM
String.replace() method JohnD Javascript 0 August 20th, 2004 06:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.