Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expressions -- Not a particular word

Status
Not open for further replies.

toddyl

Technical User
Sep 26, 2005
102
US
Hi,

I have an app that uses unix regular expressions to match subjects it will store in its memory cache. I have setup several apps as follows:

RANGE: KEY_RANGE_1.[A-T].*
RANGE: KEY_RANGE_2.[U-Z].*
RANGE: KEY_ROUND.[A-Z].*
RANGE: KEY_TOTAL.[0-9].*

I need to setup an app that will get all the expressions that do not match those above. I am trying to do something like:

RANGE: <Some form of regular expression which says get all symbols that are not in KEY_RANGE, KEY_ROUND and KEY_TOTAL>

but I do not know how to do this.

The only thing I can see where it says "does not match" is [^] function but this seems to only take ranges into account as opposed to literal strings.

Can anyone please help.

Thanks,

Toddyl
 
Unfortunately there are multiple "languages" for regular expressions, so it's difficult to answer definitively without knowing the internal implementation. Do you know what the app is written in?

Unfortunately a "does not match" is often something that has to be controlled outside the expression itself (e.g. grep -v), because if you think about it, a regular expression can match something anywhere in the string (unless it is anchored), and even if what you are searching does occur in the string, there are also components of the same string in which it does not occur, so it can still evaluate to true.

Not sure I'm making a lot of sense there, but the point is, if the app doesn't support regex for exclusions, you may need to do it another way.

Annihilannic.
 
Annihilannic,

Thanks for getting back to me.

The doc I have on the app says it uses standard Unix Regular expressions. The values after the word RANGE are taken as the pattern to match. I therefore need to come up with something that will match everything but the ranges above.

Cheers,

Toddyl
 
There is no one "standard" of Unix regular expressions, I assume it means Basic Regular Expressions (see man 5 regexp) as opposed to Extended Regular Expressions. I'm pretty sure there isn't be a way to do it with them.

There are also the Perl extensions to regular expressions, as well as the shell file globbing and extended globbing expressions, but they are not strictly REs. The latter would be useful because they support a !( some expression ) negation syntax, which you could try, but I don't hold out much hope.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top