我知道String的确切前缀.
例如它是'XXX000'
在前缀,数字和字符数量为60之后.
如何构建regexp这种情况?
在我最初的理解中它应该看起来像:
(XXX000)(\w{*})
Run Code Online (Sandbox Code Playgroud)
喜欢:前缀(一些数字或一些字符)
谢谢.
用这个 /XXX000(\w{0,60})/
/ <- Start of the regex
XXX000 <- Your constant prefix (don't really need to capture it then)
( <- Capture the following matching elements
\w <- Every characters in [a-zA-Z0-9_]
{0,60} <- Between 0 and 60 repetitions of the last element
) <- End of the group
/ <- End of the regex
Run Code Online (Sandbox Code Playgroud)
如果您不想要[a-zA-Z0-9_]字符,请使用您自己的字符类替换.
注意:您可能不需要分隔符,如果是这种情况,请记得删除分隔符.
资源:
| 归档时间: |
|
| 查看次数: |
1180 次 |
| 最近记录: |