Jump to content

Javascript Regular Expressions Break Syntax Highlighting?!


Maximus
 Share

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.

Edited by Maximus
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...