Colorize subset of line


Since stream.match() didn’t work in my case - i used a workaround:

indent preformatted text by 4 spaces
	var regexP = /P\./g;
			var regexRSDot = /RS\.\w*/g;
			var regexDTDot = /DT\./g;
			var regexDT = /DT_\w*/;
			var regexRS = /RS_\w*/;
			var regexFOAB = /FO\(AB\w*/;
			var string = stream.string;
			//var string = stream.string.replace(/^"(.*)"$/, '$1');
			var matchC = regexComment.exec(string);
			var matchP = regexP.exec(string);
			var matchRS = regexRS.exec(string);
			var matchRSDot = regexRSDot.exec(string);
			var matchDTDot = regexDTDot.exec(string);
			var matchDT = regexDT.exec(string);
			var matchFOAB = regexFOAB.exec(string);
			if(matchRS !== null){
				return ret("ruleset", "ruleset");

The Regex Pattern will be recognized now. But unfortunately the whole line will be colorized and not just a subset.

Why does this statement colorize the whole line?

if(matchRS !== null){
			return ret("ruleset", "ruleset");

How can I manage this?

Thank you.


@marijn - Hello Marijn. Could you please just tell me, how to colorize just the pattern which has been matched with the coding above? Currently it colorizes the whole line.

The regex is var regexRS = /RS_\w*/;

So it should just match xxxxxxxxxxx RS_yyyyyyyy xxxxxxxxxxx

Thank you very much.


No, I’m not going to continue responding to these posts, and I’d prefer you would stop making them. Your problem appears to be a missing grasp of basic programming and JavaScript concepts, and you should address that before you can expect to be able to write a CodeMirror mode.