[英]Java Regex to find a string which starts with SDPCDR_
what is the regular expression which i should use to match a string which starts with SDPCDR
and contains date in the format 20120826
and ends with .asn
? 我应该使用什么正则表达式来匹配以
SDPCDR
并包含日期格式为20120826
并以.asn
结尾的.asn
?
an example string is SDPCDR_delsdp3a_6091_20120826-042451.asn
示例字符串是
SDPCDR_delsdp3a_6091_20120826-042451.asn
这将工作:
^SDPCDR\w+(\d{8})-\w+.asn$
"^SDPCDR.*\\d{8}.*\\.asn$"
Pretty generous on the date part, but the string is probably specific enough already to avoid false matches. 日期部分相当宽泛,但是字符串可能已经足够具体,可以避免错误匹配。 If you're looking for a substring rather than trying to match the entire string, instead use
如果您要查找子字符串而不是尝试匹配整个字符串,请使用
"SDPCDR.*?\\d{8}.*?\\.asn"
SDPCR_[a-z_]*[0-9]{8,8}-[a-z_]*\\\\.asn
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.