Javascript regexp pattern

Discuss syntax highlighting or submit new syntax files.
Post Reply
Marcus
Posts: 23
Joined: 23 Jan 2010 23:15

Javascript regexp pattern

Post by Marcus »

RjTextEd V 6.6 installed in Windows Vista Home Basic

Using regular expression I note that the pattern delimiter are not correctly regognized, expecially if I include one character normally used to delimit literal string.
For example:

Code: Select all

var myRegExp=/('|/g;
var mySecondVar;
var myThirdVar;

the second character after the pattern start delimiter (slash) is the single quote. All the rest of the code after that character is uncorrectly recognized ad literal string (syntax hilighting show the code in the related color).
Obiously the / character has not to be confused with the divide operator: the difference lies in the fact that a slash character, used as divide operator, cannot be the first one in a expression.
So if we have

Code: Select all

myVar = function(/('|/g,otherParma);
the slash character after

Code: Select all

function(
cannot be a divide operator and it can be recognize as patter start delimiter.
If the / character is not the first character of an expression and is preceded by a string delimiter (single quote or double quote) it must be recognized ad a part of the literal.

Can I use some setting(s) of the syntax file to make RjTextEd able to correctly recognize regexp pattern delimiter?

Thank you in advance for the reply
Marcus
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

Post by Rickard Johansson »

Fixed in the next version.

I added a new block to the JavaScript syntax with a new option to only allow the block highlighting after certain characters, like ({[=, ;:

The block is called "RegEx Pattern". You may have to set the color for it manually in the options. The default color is set to dark Gray.
Marcus
Posts: 23
Joined: 23 Jan 2010 23:15

Post by Marcus »

Thank you Rickard,

I'll waiting for the beta. I'll try to use the new option in the Syntax Editor.

Kind regards
Marcus
Post Reply