Maximus Posted September 27, 2009 Share Posted September 27, 2009 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. Link to comment Share on other sites More sharing options...
Ingolme Posted September 27, 2009 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 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
Archived
This topic is now archived and is closed to further replies.