Vba match greek in regex

I am trying to match Greek characters in a regex pattern. It looks like VBA has pretty limited support for Unicode, but I can do with ASCII if possible. Here's some sample code:

Sub TestGreekRegEx()
Dim str 
str = "αυτό είναι ένα ελληνικό κείμενο"
Set regEx = CreateObject("vbscript.regexp")
regEx.Pattern = "\b[\xe1-\xfe]+\b"
Set Matches = regEx.Execute(str)
For Each Match In Matches
    MsgBox Match
Next
End Sub

      

This doesn't return any matches. Also, if I loop at the str character, the ASCII codes I get are in the range \ xE1 to \ xFE.

thank

+3


source to share


1 answer


Try

\b[\u00E1-\u03CE]+\b

      



BTW, be sure to handle the UNICODE character range.

0


source







All Articles