Re: Regular expressions
- From: Ron Rosenfeld <ronrosenfeld@xxxxxxxxxx>
- Date: Wed, 19 Sep 2007 19:00:14 -0400
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
.
- Prev by Date: Re: Regular expressions
- Next by Date: RE: Work***.Change macro doesn't run in 2007
- Previous by thread: Re: Regular expressions
- Next by thread: Re: Help with TEXTBOX control
- Index(es):