由于我是正则表达式的新手,任何人都可以给我以下正则表达式的详细解释: -
ZBC_EXTR[0-9]{0,1}\_STOCK_([A-Z]{0,1}|[0-9]{0,1})
答案 0 :(得分:1)
这是正则表达式正在寻找包含各种部分的字符串。
"ZBC_EXTR" - The string must begin with these characters
"[0-9]{0,1}" - Looks for a digit 0-9, can appear 0 times but not more than once
"\" - Escape character(Escapes the following character for regex engine)
"_STOCK_" - Must have these set of characters next
"(" - Beginning of the group expression
"[A-Z]{0,1}" - Look for alpha, capital character,can appear 0 times but not more than once
"|" - The logic OR expression
"[0-9]{0,1}" - Looks for a digit 0-9, can appear 0 times but not more than once
")" - End of the group expression
例如,以下字符串将匹配正则表达式:
ZBC_EXTR8_STOCK_
ZBC_EXTR_STOCK_
ZBC_EXTR_STOCK_F
但这些字符串不匹配:
ZBC_EXTR_STOCKF
ZBC_EXTRA_STOCK_F
ZBC_EXTR45_STOCK
正则表达式的一个很好的资源:https://www.regular-expressions.info/