Javascript regex

Javascript regex

本文关键字:regex Javascript      更新时间:2023-09-26

我需要一个正则表达式(使用 Javascript),它匹配具有任何字母数字字符或以下标点字符 ( .:; ) 的字符串,例如,至少有两个数字和两个标点字符。

匹配示例:

ab0.da;134fd
01.adas:112dd
.dasa;.3123aa

提前谢谢。

试试这个

^(?=(.*?'d){2,})(?=([^:;.]*[.:;]){2,}[^:;.]*$)['w.:;]+$
 -------------- ------------------
        |                |->match further only if there are two punctuation..
        |
        |->match further only if there are atleast two digits