无法不匹配子字符串和匹配字符串

Not able to not match substring and match string

我对正则表达式很陌生,我一直在努力寻找适合我需要的正确表达式,如下所示: 我需要了解字符串是否以 "n" 或 "p" 开头,为此我有 ^(n|p)。 接下来可能会发生任何三种组合,为此我有 (fcombination|scombination|tcombination),之后我的问题就开始出现了。 如果 "hvt" 发生在先前条件之后,我需要匹配,但如果它只是 "hv" 而不是 "hv" 则不需要匹配任何子字符串。

哪位专家可以帮忙吗?

此致

如果我明白你的意思,正则表达式 ^[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 match