dragonore
dragonore

Reputation: 803

Is there a way to continue the color coding of Sublime Text 2 or 3 when using regular expressions?

Just trying to have Sublime Text resume its color state.

enter image description here

Upvotes: 1

Views: 45

Answers (2)

ttzn
ttzn

Reputation: 2623

There is nothing wrong with Sublime Text : You have an unescaped / in your regex, which closes it prematurely. It should be \/.

Upvotes: 2

Bjorn
Bjorn

Reputation: 71950

You could try using a call to RegExp and add your regexp as a string, but it's kind of silly to change your JavaScript to fix how your editor highlights.

i.e.

return new RegExp('[~`....?', 'g').exec(str);

Having said that, if you do it this way you shouldn't probably recreate that regexp with each function call, but outside of the function, there's no need to recompile that regular expression each time.

Upvotes: 1

Related Questions