Regex type functionality in VO or Vulcan...

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
Sherlock
Posts: 63
Joined: Mon Sep 28, 2015 1:37 pm
Location: Australia mate... fare dikkum

Regex type functionality in VO or Vulcan...

Post 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
Phil McGuinness
User avatar
wriedmann
Posts: 3765
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Regex type functionality in VO or Vulcan...

Post by wriedmann »

Hi Phil,
in VO, I use the hs_regex.dll.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Sherlock
Posts: 63
Joined: Mon Sep 28, 2015 1:37 pm
Location: Australia mate... fare dikkum

Regex type functionality in VO or Vulcan...

Post by Sherlock »

Wolfgang

Is there a Vo wrapper or use examples somewhere?
Reading now.. sounds promising

Phil
Phil McGuinness
User avatar
wriedmann
Posts: 3765
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Regex type functionality in VO or Vulcan...

Post by wriedmann »

Hi Phil,
here is both my library and the DLL:
hs_regex.zip
(31.86 KiB) Downloaded 96 times
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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Jamal
Posts: 322
Joined: Mon Jul 03, 2017 7:02 pm

Regex type functionality in VO or Vulcan...

Post 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.
Sherlock
Posts: 63
Joined: Mon Sep 28, 2015 1:37 pm
Location: Australia mate... fare dikkum

Regex type functionality in VO or Vulcan...

Post 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
Phil McGuinness
Post Reply