Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Regex Question

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Regex Question

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.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Regex Question

http://www.aivosto.com/regexpr.html
claims to respond to your wish, almost verbatim.

This is just a report, not an endorsement.

On Fri, 22 Aug 2003 00:35:23 GMT, "William Barnes"
wrote:

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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
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.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Regex Question

Well it does say "The real thing is an ordinary source code module. "
Perhaps you could integrate it into applications, depending on their
distribution permission...

On Fri, 22 Aug 2003 13:26:00 GMT, "William Barnes"
wrote:

Thanks, Wild Bill.
It does look like that site's product, for $199, will add that functionality
to VBA. However, I'm looking for built-in features of VBA that can be used
in an AddIn for distribution to other users whose machines may not have
their software installed. I guess VBA doesn't have it.

"Wild Bill" wrote in message
...
http://www.aivosto.com/regexpr.html
claims to respond to your wish, almost verbatim.

This is just a report, not an endorsement.

On Fri, 22 Aug 2003 00:35:23 GMT, "William Barnes"
wrote:

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.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Regex Question

Hi William,

I'm a little late on this one, I was just doing a quick browse through
the RegExp questions

You can enable iRegExo with early binding as per Chip's suggestion or
you can use late binding as below

Dim RegExp As Object
Set RegExp = CreateObject("vbscript.regexp")

As it is a distribution I'd stick with the early binding as your RegExp
reference will be included with your file, but when I give code to
someone else I use late binding as its one less thing that the user
needs to set up


Cheers

Dave


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Regex Syllables, Harlan Grove? PJ[_3_] Excel Worksheet Functions 4 April 30th 09 08:52 PM
automated cut and paste using regex excel_newbie Excel Worksheet Functions 2 March 20th 09 12:29 PM
MS Query capabilities/regex Mike[_10_] New Users to Excel 2 June 23rd 08 09:19 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM


All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"