ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Like Operator vs Regular Expressions (https://www.excelbanter.com/excel-programming/324910-like-operator-vs-regular-expressions.html)

Chris W.

Like Operator vs Regular Expressions
 
I am trying to find out if there is anyway to simulate the
functionality of the Reular Expression's "*" when using
the Like operator. specifically: in Regular expressions
the "*" refers to Multiple Occurences, so, [\w]* mmeans
any multiple occurence of a word character,Equivalent to
[a-zA-Z0-9]. But with the Like operator "*" means "Any"
multiple characters, which includes the whole ASCII
character set. Is there a way to limit it to just
MULTIPLE characters that are just alpha-numeric.

[email protected]

Like Operator vs Regular Expressions
 
HI,
you can use vbscripts regular expression function like this..

Sub DelIt()
Dim re As Object, cell As Range
Set re = CreateObject("VBScript.Regexp")
re.Pattern = "(-[^-]*){3}$"
For Each cell In Selection
cell.Offset(0, 1).Value = re.Replace(cell.Value, "")
Next
End Sub


M$ Documentation:
http://msdn.microsoft.com/library/de.../en-us/script5
6/html/vsobjregexp.asp
Hth,
OJ


NickHK

Like Operator vs Regular Expressions
 
Chris,
<From Excel VBA help

Like Operator

? Any single character.
* Zero or more characters.
# Any single digit (0-9).
[charlist] Any single character in charlist.
[!charlist] Any single character not in charlist.



</From Excel VBA help

NickHK


"Chris W." wrote in message
...
I am trying to find out if there is anyway to simulate the
functionality of the Reular Expression's "*" when using
the Like operator. specifically: in Regular expressions
the "*" refers to Multiple Occurences, so, [\w]* mmeans
any multiple occurence of a word character,Equivalent to
[a-zA-Z0-9]. But with the Like operator "*" means "Any"
multiple characters, which includes the whole ASCII
character set. Is there a way to limit it to just
MULTIPLE characters that are just alpha-numeric.





All times are GMT +1. The time now is 06:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com