I am working with js (javascript) regex literal expressions but I guess the answer applies to all regex in some form.
I simply want to know if it is possible to do this: /\w+[more characters]/g
(please disregard the incorrect expression, it is for illustration only)
or are we locked in the finality of the meaning of meta-characters and if we what \w to hold more characters we have to write the entire range construct i.e. [a-Z...more characters]?
Since this is a yes/no question, I would appreciate examples to make this question of any use for future help.
Thanks.
You can create your own character class like this:
/[\wйцукенгшщз]+/g
And you will be able to catch not just 'a', 'b' through 'z', but also Cyrillic characters 'й', 'ц', etc.
Example (here, the last 'a' is Latin, the rest is Cyrillic):
var re = /[\wа-яА-ЯёЁ]+/;
var str = 'Славa';
var m;
if ((m = re.exec(str)) !== null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
alert(m[0]);
}