Results 1 to 4 of 4
  1. #1
    gazaman is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Oct 2018
    Posts
    2

    Matching String using Regexp Function


    Hi, I Have my pierce of code that is not working properly.I need the strSearch(the input string) string to be able to be matched to the strSearchptn (the pattern the text to conform to).However my code when i press the Command0 button it doesn't incrememnt the "regExp_Matches.Count " it is showing 0,

    Can someone maybe locate where the problem is
    NB** all the data is just test data I need to have it working to put the actual data

    The code is below

    Private Sub Command0_Click()
    Dim regExp As Object
    Dim strSearchPtn As String
    Dim strSearchText As String
    Dim strMatchingSeq As String
    Dim myCount As Integer


    strSearchPtn = "[0-9]"
    strSearchText = "2018"
    strMatchingSeq = "The Sequence is Matched" 'test variable


    Set regExp = CreateObject("vbscript.regexp")


    With regExp
    .Pattern = strSearchPtn
    .IgnoreCase = True
    .Global = True
    End With
    Set regExp_Matches = regExp.Execute(strSearchText)
    myCount = regExp_Matches.Count 'test variable
    If regExp_Matches.Count = 1 Then
    Me.txtTextBox = strMatchingSeq
    Else
    Me.txtTextBox = "Nothing Found"
    End If




    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    cant you use a query?

  3. #3
    gazaman is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Oct 2018
    Posts
    2
    Ideally what I want to do is to have an application that takes a user input string from a form to check if it is within a specific Alphnumeric range in a database column, any ideas besides using regex ?

    For example:

    user input is : "81E00912" SEARCH SEQUENCE is " 81E00001 - 81E00918 "
    or "WPOZZZ91ZES800912" search sequence "WPOZZZ91ZES800001 - WPOZZZ91ZES800918"

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    I agree, can be done in a query if my understanding is correct - which is there is one requirement which is

    the last 3 characters need to be in the range 001 to 918

    is this correct?

    Alternatively

    the first x number of characters must match (something? if so what?), x being length of user input-3
    and the last 3 characters need to be in the range 001 to 918

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

Similar Threads

  1. Replies: 14
    Last Post: 04-30-2018, 01:31 PM
  2. RegExp to Find String at END of a String
    By Micron in forum Programming
    Replies: 3
    Last Post: 01-17-2018, 09:43 PM
  3. matching part of the string from two columns
    By hoachen in forum Queries
    Replies: 4
    Last Post: 12-20-2011, 01:54 PM
  4. Replies: 4
    Last Post: 12-02-2011, 11:20 AM
  5. String Matching
    By tuna in forum Programming
    Replies: 1
    Last Post: 05-16-2010, 12:22 PM

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