Answer the question
In order to leave comments, you need to log in
js regex
There is a format line #xxxxyyyyyyy where x is a lowercase Latin letter (there are strictly 4 of them), and y is a number from 0 to 9 (it can be arbitrarily)
Task: carve a lattice, put letters in the first variable, numbers in the second. I'm not good at regulars, please help.
Answer the question
In order to leave comments, you need to log in
In fact, there is no need for regularity.
var source = "#abcd123123123123123123123123";
var part1 = source.substr(1, 4);
var part2 = source.substr(5, source.length - 5);
var text = '#abcd123123123123123123123123';
var mtch = text.match(/^#([a-z]{4})([0-9]*)$/);
mtch[1]; // буквы
mtch[2]; // цифры
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question