Results 1 to 4 of 4

Instr with RegEx - Runtime error 5017 (RegEx Code provided)

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,103

    Instr with RegEx - Runtime error 5017 (RegEx Code provided)

    Hello,

    I found the following Instr function with RegEx.

    The code Always stuck at 'set found = regEx.Execute(SearchIn).

    Can anyone help me what's wrong with it?

    Note that I've also checked the Microsoft VBScript Regular Expressions (1.0 or 5.5) and still is giving the same error.

    Public Function InStrRegEx(ByVal searchIn As String, ByVal searchFor As String) As Long
        Dim regEx As Object, found As Object
        If Len(searchIn) > 0 And Len(searchFor) > 0 Then
            Set regEx = CreateObject("VBScript.RegExp")
            regEx.Pattern = searchFor
            regEx.Global = True
            regEx.IgnoreCase = True
            Set found = regEx.Execute(searchIn)        <-----when debug, this is where it's shown
            If found.Count <> 0 Then InStrRegEx = found(0).FirstIndex + 1
        End If
    End Function
    NOTE: Was able to resolve by using "\\([0-9]+) ([0-9]+)\\" instead of "\## ####\"
    Last edited by dluhut; 09-28-2018 at 05:21 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Simplification for regex code to replace numbers in a comma delimited string
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2018, 06:30 AM
  2. ByRef type Mismatch error with RegEx
    By Bob1980 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2017, 02:18 PM
  3. [SOLVED] RegEx pattern, code exacuting but doing nothing
    By capson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-23-2015, 03:48 PM
  4. Not able to use the regex in code...
    By lifeankit in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-22-2014, 06:54 AM
  5. Need a new regex .pattern for comparison code
    By Swiss Cheese in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2012, 09:16 PM
  6. RegEx Object Error
    By duckboy1981 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-03-2009, 04:20 AM
  7. Runtime Error 13 in provided Macro
    By BenOggo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2008, 03:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1