Jump to content

Javascript Regular Expressions Break Syntax Highlighting?!


Maximus

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...