Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何编写满足以下要求的正则表达式:1)必须恰好是一个 7 位数字的序列 2)某处的 EDD 或 FINAL 字
怎么样
^(?=\d*(EDD|FINAL)\d*$)(?=(\D*\d\D*){7}$)
这应该可以解决问题:
#[0-9]{7}(EDD|FINAL)?# //EDD OR FINAL are optional
或者
#[0-9]{7}(EDD|FINAL)+# //if EDD OR FINAL must be there