Re: RegEx
- From: "HSalim[MVP]" <HSalim@xxxxxxx>
- Date: Fri, 10 Mar 2006 09:54:33 -0500
Steve,
Boy, you are really a genius at this. Do you work with RegEx a lot or are
you just plain brilliant?
Thanks for the help.
Regards
HS
"Steve Fulton" <cerberus40@xxxxxxxxxxx> wrote in message
news:op.s569mvb8i0ix9l@xxxxxxxx
HSalim[MVP] wrote:
I wanted to add support for table names enclosed in square brackets, and
added my comments.
This works for me but if there is a more compact definition, I'd love to
learn from it .
An updated definition and a test text string are pasted below if you want
to
test it.
If you can absolutely, positively, 100% guarantee that every table name
that starts with a "[" ends with a "]", you can define each table name
as "\[?\w+\]?". If there is *any* possibility, no matter how small,
that this is not the case, you need to test for each case separately,
as you do now.
However, your current pattern will match only cases where all the table
names are in brackets or none of them are. If you have a table name in
the form "[name1].name2.[name3]", your pattern will not find all of it
(it will match "[name1]").
Here is a more compact pattern that will find your example table names
and table names that have mixed bracket/no bracket formats:
sPatrn = "\b(?:from|join)\s" _
& "(" _
& "(?:(?:\w+|\[\w+\])?\.){0,2}" _
& "(?:\w+|\[\w+\])" _
& ")"
Note that this pattern will also find names in the form ".word.word",
which is not on your list of valid formats. To eliminate that
possibility, you need to add a negative look-ahead:
sPatrn = "\b(?:from|join)\s" _
& "(?!(?:\.\[?\w+\]?){2})" _
& "(" _
& "(?:(?:\w+|\[\w+\])?\.){0,2}" _
& "(?:\w+|\[\w+\])" _
& ")"
--
Steve
War is God's way of teaching Americans geography. -Ambrose Bierce
.
- Follow-Ups:
- Re: RegEx
- From: Michael Harris \(MVP\)
- Re: RegEx
- References:
- Prev by Date: Re: Loop through a registry branch for all keys.....
- Next by Date: Getting Classes into my VBScript?
- Previous by thread: Re: RegEx
- Next by thread: Re: RegEx
- Index(es):
Relevant Pages
|