Problems with Reg Pattern "[^"]\$[A-Z]*[0-9]"

E

ExcelMonkey

I am having a problem usng this regex pattern in VBA:

[^"]\$[A-Z]*[0-9]

When I put it into quotes:

"[^"]\$[A-Z]*[0-9]"

It highlights the first ] and says Invalid Character.

I am assuming that it has something to do with the way VBA uses quotes for
text strings. What do I have to do to get around this?

Thanks

EM
 
D

dougw

Not sure, but I think I read something about that before.... and they used
double quotes...

""[^\$[A-Z\*[0-9]""
 
R

Rick Rothstein \(MVP - VB\)

I do not work with RegEx myself (or at least I haven't for many, many years
now), but I think your problem is with the embedded quote mark. You must
double them up with inside a String constant (text with quote marks at the
beginning and end of the text). Try this pattern and see if it works...

"[^""]\$[A-Z]*[0-9]"

Rick
 
R

Ron Rosenfeld

I am having a problem usng this regex pattern in VBA:

[^"]\$[A-Z]*[0-9]

When I put it into quotes:

"[^"]\$[A-Z]*[0-9]"

It highlights the first ] and says Invalid Character.

I am assuming that it has something to do with the way VBA uses quotes for
text strings. What do I have to do to get around this?

Thanks

EM


"[^""]\$[A-Z]*[0-9]"

should work just fine.

--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top