Page 1 of 1

Javascript regexp pattern

Posted: 16 Aug 2010 19:47
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

Posted: 22 Aug 2010 18:35
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.

Posted: 22 Aug 2010 19:26
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