Answer the question
In order to leave comments, you need to log in
How to implement a regular expression?
I want to make my own highlighting and everything is going fine, but these regular seasons are difficult for me :) Help me make the highlighting right.
var find = new Array(
/(function|var|if|else|return|\&\&|\?|\:|===|==|=|\<|\>|\+\+|\-\-|\*|\%|\$|\@|\!)/g,
/(setTimeout|appendTo)/g,
/\/\/(.+)/g
);
var replacing = function(syntax,i){
var arr = new Array(
"<span class=\""+ syntax +" ff\">$1</span>",
"<span class=\""+ syntax +" fn\">$1</span>",
"<span class=\""+ syntax +" cc\">//$1</span>"
);
return arr[i];
}
Answer the question
In order to leave comments, you need to log in
And I thought that I don’t like ready-made solutions :D
\$[a-z]+[^ ] // вместо a-z укажи все допустимые символы для переменных
Try
var find = new Array(
/(function|var|if|else|return|\&\&|\?|\:|===|==|=|\<|\>|\+\+|\-\-|\*|\%|\$\w*|\@|\!)/g,
/(setTimeout|appendTo)/g,
/\/\/(.+)/g
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question