regexp - how to do an anti-match on a word

Boosters: I'm having trouble determining a regular expression that will do the following: 1. Match the following strings: TermGeMstreamIPTriplePlay_11.0.IpTxMstream_0.DefaultGateway TermGeMstreamIPTriplePlay_11.0.VplsTxMstream_0.CurMbps TermGeMstreamIPTriplePlay_11.0.MplsTxMstream_0.AvgMbps TermGeMstreamIPTriplePlay_11.0.MacTxMstream_0.Address 2. But not match the string: TermGeMstreamIPTriplePlay_11.0.TrafficTxMstream_0.RampStart So, essentially match the strings with IpTx, VplsTx, MplsTx and MacTx, but not match strings with TrafficTx. Right now, I have: .*\.(IpTx|MacTx|MplsTx|VplsTx)Mstream_0\..* This works, however, it is not very robust because there may be more entries added to the matching words over time. Is there someway to do an anti-match on the word "TrafficTx"? Something like: .*\.(!TrafficTx)Mstream_0\..* Thanks, David

David Ward wrote:
Boosters:
I'm having trouble determining a regular expression that will do the following:
1. Match the following strings: TermGeMstreamIPTriplePlay_11.0.IpTxMstream_0.DefaultGateway TermGeMstreamIPTriplePlay_11.0.VplsTxMstream_0.CurMbps TermGeMstreamIPTriplePlay_11.0.MplsTxMstream_0.AvgMbps TermGeMstreamIPTriplePlay_11.0.MacTxMstream_0.Address
2. But not match the string: TermGeMstreamIPTriplePlay_11.0.TrafficTxMstream_0.RampStart
So, essentially match the strings with IpTx, VplsTx, MplsTx and MacTx, but not match strings with TrafficTx.
Right now, I have:
.*\.(IpTx|MacTx|MplsTx|VplsTx)Mstream_0\..*
This works, however, it is not very robust because there may be more entries added to the matching words over time.
Is there someway to do an anti-match on the word "TrafficTx"? Something like:
.*\.(!TrafficTx)Mstream_0\..*
Use a zero width lookahead assertion, so something like: .*\.(?!TrafficTx)\w+Mstream_0\..* HTH, John.
participants (2)
-
David Ward
-
John Maddock