I want to negate the outcome of the regex pattern, so that it should return everything except the regex outcome.
Sample String:
SMTP:[email protected];smtp:[email protected];sip:[email protected]
I have written a below regex which gives output as- [email protected]
(?<=SMTP:)(.*?)(?=;)
Now i want everything except the above outcome i.e
SMTP:;smtp:[email protected];sip:[email protected]
I am trying to negate but it is not working.
Any help is much appreciated.
It might be overcomplicated, but if you need multiline matching and a smtp account can be in the beginning of a line, this:
would match:
SMTP:;up until anotherSMTPSMTPHave a look at some tests here.
This can break down if an email name contains
SMTPin it, but I hope you won t have any.Another approach is use your matching regex,
(?<=\SMTP:)(.*?)(?=\;), and keep deleting what it matches from the string.