Re: Regular expressions

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Wed, 19 Sep 2007 12:24:02 -0700, Dave <Dave@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

Hello,

The snippet of code below builds a new string "Newval" based on the pattern
[A-Z]
and that works fine but what if I wanted to exclude values .
For example I could set a pattern of "[)(*&^]" how would I code it to
exclude those values?

With RegExp
.Global = True
.Pattern = "[A-Z]"
End With
Set Myrange = Active***.Range("A1:A10")
For Each C In Myrange
newval = ""
Set Collection = RegExp.Execute(C.Value)
For Each RegMatch In Collection
newval = newval & RegMatch
Next
Next


D

Perhaps you just need to negate the character class:

"[^)(*&^]"

which translates as:

Match a single character NOT present in the list
")(*&^"


--ron
.


Quantcast