Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC:

Regex type functionality in VO or Vulcan... 09 Dec 2022 08:17 #24711

  • Sherlock
  • Sherlock's Avatar
  • Topic Author


  • Posts: 54
  • 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

    Please Log in or Create an account to join the conversation.

    Regex type functionality in VO or Vulcan... 09 Dec 2022 09:45 #24713

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • Hi Phil,
    in VO, I use the hs_regex.dll.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Regex type functionality in VO or Vulcan... 10 Dec 2022 01:25 #24716

    • Sherlock
    • Sherlock's Avatar
    • Topic Author


  • Posts: 54
  • Wolfgang

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

    Phil
    Phil McGuinness

    Please Log in or Create an account to join the conversation.

    Regex type functionality in VO or Vulcan... 10 Dec 2022 06:40 #24717

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • Hi Phil,
    here is both my library and the DLL:

    File Attachment:

    File Name: hs_regex.zip
    File Size:32 KB

    And this is the code behind a button to check if an expression is covered by the regular expression:
    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

    www.riedmann.it - docs.xsharp.it
    Attachments:

    Please Log in or Create an account to join the conversation.

    Regex type functionality in VO or Vulcan... 11 Dec 2022 07:16 #24720

    • Jamal
    • Jamal's Avatar


  • Posts: 309
  • 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.
         local o as object 
         
         local Str1 := "" 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.

    Please Log in or Create an account to join the conversation.

    Last edit: by Jamal.

    Regex type functionality in VO or Vulcan... 12 Dec 2022 01:11 #24722

    • Sherlock
    • Sherlock's Avatar
    • Topic Author


  • Posts: 54
  • 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

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1