问题
I have some links:
utmcsr=rdstation|utmccn=curso-intro-coaching|utmcmd=inbound|utmctr=link3
utmcsr=rdstation|utmccn=agenda-psc|utmcmd=email
utmcsr=rdstation|utmccn=pnl-porto-alegre
I want to build a regex expression that matches the rdstation not followed by inbound OR email.
I've tried rdstation(?!(email|inbound))
but it doesn't worked.
回答1:
The problem is that your negative lookahead is anchored to the position directly after rdstation. It would only exclude strings like this:
rdstationemail asdf 123 4
You need to make sure it can match anywhere after rdstation:
rdstation(?!.*(email|inbound))
Working example here.
来源:https://stackoverflow.com/questions/44204359/regex-match-a-word-not-followed-by-two-other-words