comparing string using regular expression in VBA

  • Thread starter Thread starter perlperl
  • Start date Start date
P

perlperl

how to regular expression in VBA

my string is "The operating system is Win32"

This is what i do in perl
if $string =~ /Thes operating system is Win32|Linux|Unix/ {

}

which mean the OS can be unix Linux or Win32

How this can be achieved in VBA
 
If oRE.Test("The operating system is Win32") Then
this won't work, as i said in my example, it can be eithe Win32, Linux
or Unix (also I don't want 3 different if statements....)

can I do

If oRE.Test("The operating system is Win32|Linux|Unix") Then
 
John showed you a pattern that will match the statement:

"The operating system is X"

where X can be "Win32", or "Linux", or "Unix".

If that's not what you want, please describe what you /do/ want.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
actually my bad, i din't gave the correct example.
to be more specific, i m looking to comapre IP address which can be of
the format
22.223.22.234 which is integer.integer.integer.integer (integer can be
1 or 2 or 3 digit)

i tried the pattern
oRE.Pattern = "\d+.\d+.\d+.\d+"

If oRE.Test(.Text) Then ' .Text contains the IP address

It didn't worked
 
If my IP is 4.4.4.4
then oRE.Pattern = "[0-9]+.[0-9]+.[0-9]+.[0-9]+" works

but if the IP is 44.4.4.4, it does not work
 
Back
Top