我对正则表达式非常陌生,我一直在努力寻找符合我需要的正确的正则表达式,如下所示:我需要知道字符串是以"n“开头还是以"p”开头,为此我有^(n|p)。接下来,任何三种组合都可能发生,为此,我有(f组合|s组合|t组合),在那之后,我的问题开始上升。如果"hvt“发生在前面的条件之后,我需要匹配,但如果只是"hv”而不是"hv“,则不需要匹配任何子字符串。
有没有专家能帮上忙?
问候
发布于 2019-03-19 03:20:17
如果我明白你在找什么,正则表达式^[np][fst]combination(?!hv(?!t)).*应该匹配
nfcombinationhvt //match
pscombinationhvt //match
ntcombinationhvt //match
nfcombinationdrums //match
pscombinationguitar //match
ntcombinationkicker //match
nfcombinationhvxxx //no match
pscombinationhvzz //no match
ntcombinationhva //no match
nfcombinationhv //no match
pscombinationhv //no match
ntcombinationhv //no matchhttps://stackoverflow.com/questions/55228446
复制相似问题