R
R
rd1002021-11-02 17:04:19
JavaScript
rd100, 2021-11-02 17:04:19

How to make a regular expression that checks for 2 or more conditions in random order?

There is a task where you need to check a string for the fact that it has at least 5 letters and at least 4 numbers, all this can be in any order in the string.
How can we check this with a single regular expression?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2021-11-02
@rd100

/^(?=(?:.*?[a-z]){5})(?=(?:.*?\d){4})/i

S
spaceatmoon, 2021-11-02
@spaceatmoon

https://regex101.com/r/AD7E0W/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question