Results 1 to 5 of 5
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365

    Reg Expression

    I want to get just a-z from a string and using this
    Code:
    Function AlphaOnly(Inval) As String
        Dim re As Object, REMatches As Object
        Set re = CreateObject("vbscript.regexp")
        re.Pattern = "\D+"
        If (re.Test(Inval) = True) Then
            Set REMatches = re.Execute(Inval)
            AlphaOnly = REMatches(0)
        End If
        Set REMatches = Nothing
        Set re = Nothing
    End Function
    Maybe that's overkill and there's a better method ?
    But also a bit intrigued, if inVal contains () why is the opening bracket also returned.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Please provide sample data and desired result.

    Appears to return anything that is not a number.

    Review https://www.appsloveworld.com/vba/20...numeric-string
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    It could be "001xx(99)"
    You want just "xx" but get "xx("

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did you review article from link in post 2?

    Try pattern "[a-zA-Z]+"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    Thank you, sorted.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 10-15-2020, 10:13 AM
  2. Replies: 2
    Last Post: 03-11-2019, 01:26 PM
  3. Replies: 2
    Last Post: 11-16-2017, 03:33 AM
  4. Replies: 4
    Last Post: 05-03-2016, 01:51 PM
  5. Replies: 2
    Last Post: 11-20-2012, 03:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums