Thread: Regex Question
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
William Barnes William Barnes is offline
external usenet poster
 
Posts: 15
Default Regex Question

A Regular Expression ("Regex") is a string with defined metacharacters
(which may vary among Regex engines) that is used by a Regex engine to
examine another string for, among other things, a match. You may wish to
refer to http://www.opengroup.org/onlinepubs/...99/xbd/re.html or other
sources for more info. They are used extensively in Perl programming
scripts.

As an example, if the Like operator supported regexes, then I could write a
line of code that would look something like this:

If cell.value Like "[A-Za-z]+ - [0-9]+" Then
'Do Something
End If

In the above snippet, where cell is a Range Object that represents a cell on
a Worksheet, the condition would be met if the cell contained one or more
upper or lowre case alphabetic characters followed by a space, then a
hyphen, then another space, then one or more numeric characters.

"Virginia Morris" wrote in message
...
William -

It's my understanding that the Like operator in VBA for Excel is intended

to
be used for string comparisons - could you give an example of a regular
expression?

"William Barnes" wrote in message
.. .
Using Excel 2000 under Win2K:

Is there a way in VBA to utilize regular expressions? The Like operator
doesn't seem to fully support them.