Are regular expressions only for searching or can they also be used for
matching? I read a 4GuysFromRolla article that only mentioned searching. I
was wondering if it's possible to do something like the following:
if Selection=[a-z/A-Z/0-9] then...
...or better yet:
If instr(Selection,[a-z/A-Z/0-9])=1 then...

Signature
Bryan
Helmut Weber - 05 Jun 2007 23:57 GMT
Hi Bryan,
>Are regular expressions only for searching or can they also be used for
>matching? I read a 4GuysFromRolla article that only mentioned searching. I
[quoted text clipped - 3 lines]
>
>If instr(Selection,[a-z/A-Z/0-9])=1 then...
this is about the same.
You can search the selection using a wildcard search.
Sub Test334()
Dim r As Range
Set r = Selection.Range
With r.Find
.Text = "[a-z][A-Z][0-9]"
.MatchWildcards = True
If .Execute Then
MsgBox "yes"
End If
End With
End Sub
When searching the selection,
previously parameters (options) are remembered.
Not so, IMHO, if you define a new range.
Though, there are a lot of peculiarities...
HTH

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Jay Freedman - 06 Jun 2007 00:55 GMT
>Are regular expressions only for searching or can they also be used for
>matching? I read a 4GuysFromRolla article that only mentioned searching. I
[quoted text clipped - 5 lines]
>
>If instr(Selection,[a-z/A-Z/0-9])=1 then...
Check the VBA help topic about the Like operator. It's similar to
regular expressions, although (typical Microsoft) not quite the same.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.