Page 1 of 1
Regex type functionality in VO or Vulcan...
Posted: Fri Dec 09, 2022 7:17 am
by Sherlock
Lots of Data strings [ imported ] where users have entered text like "Instagram" or "Facebook" or https:// http and url data.
Data Invalid to be fed to major holiday portals..
What is the simplest way to parse this data from a string besides a lot of DO CASE, SUBSTR At(
Regex sounds good but how to use in VO.?
Phil
Regex type functionality in VO or Vulcan...
Posted: Fri Dec 09, 2022 8:45 am
by wriedmann
Hi Phil,
in VO, I use the hs_regex.dll.
Wolfgang
Regex type functionality in VO or Vulcan...
Posted: Sat Dec 10, 2022 12:25 am
by Sherlock
Wolfgang
Is there a Vo wrapper or use examples somewhere?
Reading now.. sounds promising
Phil
Regex type functionality in VO or Vulcan...
Posted: Sat Dec 10, 2022 5:40 am
by wriedmann
Hi Phil,
here is both my library and the DLL:
And this is the code behind a button to check if an expression is covered by the regular expression:
Code: Select all
method CheckRegEx( oExpression as EnhancedSLE, oTest as EnhancedSLE, oResult as EnhancedSLE ) as logic pascal class DokTabEdit
local cExpression as string
local cTest as string
local oRegex as clsHs_RegEx
local lMatch as logic
cExpression := AllTrim( oExpression:Value )
if SLen( cExpression ) == 0
ErrBox( self, "no expression" )
self:SetFocusDelayed( oExpression )
return false
endif
cTest := AllTrim( oTest:Value )
if SLen( cTest ) == 0
ErrBox( self, "no test value" )
self:SetFocusDelayed( oTest )
return false
endif
debOut( "Compare " + cTest + " to " + cExpression )
oRegex := clsHs_RegEx{ cExpression, 3 }
lMatch := oRegex:Match( cTest )
oRegex:CleanUp()
if lMatch
oResult:Value := "fits"
else
oResult:Value := "does NOT fit"
endif
return lMatch
HTH
Wolfgang
Regex type functionality in VO or Vulcan...
Posted: Sun Dec 11, 2022 6:16 am
by Jamal
Here we go:
You can use
Microsoft VBScript Regular Expressions 5.5 library in
VO 2.8 - 2838 as in the the following example. The library is normally installed in Windows, so you won't have to install yourself.
Note: in earlier versions of VO, you need to use OleAutoObject instead of OleAutoObjectEx.
Code: Select all
local o as object
local Str1 := "jam@asder.com" as string
local Str2 := "jam@asder" as string
o := OleAutoObjectEx{ "VBScript.RegExp"}
if o:fInit
o:@@global := true
o:ignorecase := true
o:Pattern := "^([a-zA-Z0-9_-.]+)@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$"
If o:test(Str1)
? "Valid email address", Str1
Else
? "Invalid email address", Str1
EndIf
If o:test(Str2)
? "Valid email address", Str2
Else
? "Invalid email address", Str2
EndIf
endif
o := NULL_OBJECT
The above is late bound object, if you want to create a strongly typed class, you can generate an Automation Server classes for the various classes contained in the library.
Regex type functionality in VO or Vulcan...
Posted: Mon Dec 12, 2022 12:11 am
by Sherlock
OleAutoObjectEx{ "VBScript.RegExp"}
Ok... see what you are doing.
I will write a wrapper around the native DLL ..
Using mySQL REGEX built it and some other hack code I can move on.
Over the immediate problem.
Will come back to this.. Thanks