Michael
Michael

Reputation: 303

Regular Expression: 3 numbers over 4

How do you write a regular expression that has at least 3 over 4?

Example:

28 -> false

5555 -> true

6498 -> true

332 -> false

234789 -> true

Thank you!

Upvotes: 1

Views: 33

Answers (1)

vks
vks

Reputation: 67968

^(?=(?:\d*[5-9]){3,})\d+$

You can use lookahead for this.See demo.

https://regex101.com/r/tD0dU9/5

Upvotes: 2

Related Questions