Regular expressions in jQuery selector

Can I choose to use regex in jQuery? Sort of

$('input[name=^[a-z]+_[1-9].*]')
+3
source share
2 answers

Nothing is built in there, but you can use the filter () method to achieve the same goal:

$('input').filter(function () { return /^[a-z]+_[1-9].*/.test(this.name); })
+18
source

You can find the regex selector here (James Padolsey), so named in your case:

$('input:regex(name,^[a-z]+_[1-9].*)');
+4
source

Source: https://habr.com/ru/post/1761551/


All Articles