[英]How to translate java regular expression to javascript regular expression
I will like to translate the Java Regex 我想翻译Java Regex
(\\\p{Upper}{2})(\\\d{2})([\\\p{Upper}\\\p{Digit}]{1,30}+)
to JavaScript Regex. 到JavaScript正则表达式。 I tried 我试过了
([A-Z]{2})([0-9]{2})([A-Z][0-9]{1,30}+)
This translation wouldn't compile. 该翻译将无法编译。 Any help will be highly appreciated. 任何帮助将不胜感激。
You have separated last [\\\\\\p{Upper}\\\\\\p{Digit}]
into [AZ][0-9]
but it should be [A-Z0-9]
您已将最后一个[\\\\\\p{Upper}\\\\\\p{Digit}]
分隔为[AZ][0-9]
但应为[A-Z0-9]
Just try with: 只需尝试:
([A-Z]{2})([0-9]{2})([A-Z0-9]{1,30}+)
You can also replace 0-9
with \\d
, so: 您也可以用\\d
替换0-9
,所以:
([A-Z]{2})(\d{2})([A-Z\d]{1,30}+)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.