I have regex as follows:
/^(\d|-|\(|\)|\+|\s){12,}$/
This will allow digits, (, ), space. But I want to ensure string contains atleast 8 digits.
Some allowed strings are as follows:
(1323 ++24)233
24243434 43
++++43435++4554345 434
It should not allow strings like:
((((((1213)))
++++232+++
Use
Look aheadwithin your regex at the start..(?=(.*\d){8,})iszero width look aheadthatchecksfor 0 to many character (i.e.*) followed by a digit (i.e\d) 8 to many times (i.e.{8,0})(?=)is called zero width because it doesnt consume the characters..it just checksTo restict it to 14 digits you can do
try it here