Maximus Posted September 27, 2009 Report Share Posted September 27, 2009 (edited) For some reason, I just came across this today, and its incredibly annoying. Using a simple regular expression such as the below breaks syntax highlighting in my editor (Dashcode in this case). Frankly, using this kind of syntax makes no sense anyways as strings (even expressions) should always be used inside " or ', but you can't do that here for some reason. string.replace(/blabla/, ''); Any suggestions? All I want to do is to be able to replace ALL occurrences of a string quickly and easily. Edited September 27, 2009 by Maximus Link to comment Share on other sites More sharing options...
Ingolme Posted September 27, 2009 Report Share Posted September 27, 2009 Notepad++ works with regular expressions. In Javascript they're marked in blue.Since you're only replacing a string, then this should work: string.replace('example',''); The replace method accepts both strings and regular expressions as the first parameter. Link to comment Share on other sites More sharing options...
Synook Posted September 27, 2009 Report Share Posted September 27, 2009 Frankly, using this kind of syntax makes no sense anyways as strings (even expressions) should always be used inside " or ', but you can't do that here for some reason.JavaScript has another special type of literal, the "regular expression". It's not a string. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now