We need to mimic “AND” functionality using look ahead expression (?=expr). See the construct below:

^(?=.*?expr)(?=.*?expr)(?=.*?expr).*$

This functionality works in Java/Phyton/Perl/PHP and many other languages, however it might not be available in JavaScript. Check latest JS specification and let me know if this has changed.

EXAMPLE:

^(?=.*?(\b\d\d\d-\d\d\d\b))(?=.*?(3D))(?=.*?Demo{1}).*$

Will match:
111-234 sometext 3D Demo

Will not match:
1113-223 sometext 3D Demo
If you would not use \b at the end and start of the expression, it would also match the above line.

Read also:

https://www.regular-expressions.info/lookaround.html

0
Would love your thoughts, please comment.x
()
x