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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegExp to Exclude String

Status
Not open for further replies.

TheInsider

Programmer
Jul 17, 2000
796
CA
Hi,

I'm using the VBScript.RegExp library in VBA. What I'm trying to do is search as CSV string to find a substring that doesn't match a given criteria. I'm not interested in using the Matches collection; I only want to know True or False whether the criteria was met.

For example, if I have the following string:
",Z(A),Z(A),Z(A)"

I need a regular expression that will tell me if there is a substring that doesn't match "Z(A)". In the above case, this would be false. (The expression I need should be designed to ignore commas.)

Now, if I have the following string:

",Z(A),A,Z(A)"

I want to be alerted to the fact that "A" isn't equal to the string "Z(A)"

Also, with:

",Z(R),Z(A)"

I want to be alerted that "Z(R)" isn't equal to "Z(A)".

Apparently, Microsoft's implementation is supposed to have an exclusion code ?! however, it doesn't seem to do anything.

I.e. "(?!Z\(A\))" doesn't work and neither does "(Z\(A\)){0}"

Thanks
 
Ah, I got it. It was simply "[^\,][^Z][^\(][^A][^\)]"
I should have figured it out sooner :p duh!
 
Oh well, I fudged it by doing a If Len(Replace$(..., "Z(A)", "")) > 0 Then ...
 
It's a scripting language. If it works then it isn't a fudge. [2thumbsup]

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top