How to write a regular expression that checks that the line contains either 2-3 capital letters of the Russian alphabet, or 3-4 capital letters of the Latin alphabet?
It works with me only with two separate regulars: [А-Я]{2,3} and [AZ]{3,4} .
How to write a regular expression that checks that the line contains either 2-3 capital letters of the Russian alphabet, or 3-4 capital letters of the Latin alphabet?
It works with me only with two separate regulars: [А-Я]{2,3} and [AZ]{3,4} .
Using the pipe (symbol | ) will help in the selection.
Will find only the specified number of repetitions, more or less - already a failure.
let log = document.querySelector('#log'), test = document.querySelector('#test'); test.addEventListener('input', e => { if(/^(?:[а-яё]{2,3}|[az]{4,6})$/i.test(test.value)){ log.style.color = 'green'; log.innerHTML = 'Passed!'; }else{ log.style.color = 'red'; log.innerHTML = 'Failed'; } }); #test:focus{outline: none;} <input type='text' id='test' autofocus /><br /> <span id='log'></span> ё not included in the set az. Discrimination! - user207618Source: https://ru.stackoverflow.com/questions/560716/
All Articles
|if there are no other characters needed. Or provide more data on the line in the question. - Visman