Results 1 to 18 of 18

Possible to filter an array using a Regular Expression (not using helper columns)?

Threaded View

Rhudi Possible to filter an array... 11-15-2021, 03:43 PM
mehmetcik Re: Possible to filter an... 11-15-2021, 03:51 PM
Rhudi Re: Possible to filter an... 11-15-2021, 05:29 PM
JEC. Re: Possible to filter an... 11-15-2021, 05:12 PM
JEC. Re: Possible to filter an... 11-15-2021, 05:31 PM
Rhudi Re: Possible to filter an... 11-16-2021, 09:37 AM
jindon Re: Possible to filter an... 11-16-2021, 08:42 PM
jindon Re: Possible to filter an... 11-30-2021, 05:00 PM
Rhudi Re: Possible to filter an... 12-02-2021, 01:02 AM
Rhudi Re: Possible to filter an... 11-30-2021, 02:30 PM
jindon Re: Possible to filter an... 12-02-2021, 01:05 AM
bsalv Re: Possible to filter an... 12-02-2021, 03:41 AM
Rhudi Re: Possible to filter an... 12-02-2021, 09:42 AM
bsalv Re: Possible to filter an... 12-02-2021, 02:01 PM
chronjy Re: Possible to filter an... 12-02-2021, 04:54 PM
jindon Re: Possible to filter an... 12-03-2021, 12:55 AM
Rhudi Re: Possible to filter an... 12-07-2021, 03:38 PM
jindon Re: Possible to filter an... 12-07-2021, 04:06 PM
  1. #1
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    201

    Possible to filter an array using a Regular Expression (not using helper columns)?

    If this is simple, please point me at a link? I have searched, but perhaps don't know how to pinpoint my search. (Syntax is king.)

    The basic part of my question is, can I filter an array, using a command like:
    newArray = Filter(existingArray, "some matching RegEx string")
    So... This may be a stupid question anyway. I'm just curious if a real internal Filter method does exist.

    This code appears to work well. I pass it an array. It returns a smaller array of matches.
    Function FilterArrayRegEx(arr As Variant, RegExToMatch$) As Variant
    Dim regexOne As Object
    Dim LocalLine As Variant, Match As Variant, theMatches As Variant, IgnoreCase As Variant
    '
    Dim stringOne$, strMatches$, arrMatches$()
    '
    Set regexOne = New RegExp
    '
    With regexOne
        .Pattern = RegExToMatch
    '    .MultiLine = True        ' not relevant in this use
    '    .Global = True           ' not needed for IP addresses
    '    .IgnoreCase = IgnoreCase ' not needed for IP addresses
    End With
    '
        For Each LocalLine In arr
            stringOne = LocalLine
            Set theMatches = regexOne.Execute(stringOne)
            For Each Match In theMatches
                strMatches = IIf(Len(strMatches), strMatches & vbCrLf & LocalLine, LocalLine) ' This only skips a pesky leading vbCrLf
            Next
        Next
        arrMatches = Split(strMatches, vbCrLf)
        FilterArrayRegEx = arrMatches
        strMatches = vbNullString
        Erase arrMatches
    End Function
    I'm also not certain if I need to dig into the 'Multiline' parameter to simplify my code.
    Last edited by Rhudi; 12-02-2021 at 09:43 AM. Reason: correct title

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Look up value without helper column and array
    By jackson_hollon in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-14-2020, 02:20 AM
  2. [SOLVED] Helper column instead of array?
    By trolle in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-13-2018, 10:19 AM
  3. [SOLVED] Adapt array formula to remove need for helper row
    By JayUSA in forum Excel General
    Replies: 2
    Last Post: 09-20-2017, 10:56 PM
  4. [SOLVED] Using array formula instead of creating a helper column
    By jasonleewkd in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-10-2014, 12:55 PM
  5. [SOLVED] Removing helper columns, need array substitute (attachment)
    By ottoex in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-08-2014, 05:13 AM
  6. Helper Column Won't Filter
    By Gard5096 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2014, 04:46 PM
  7. Array Formulas instead of helper columns
    By ElmerS in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 11-25-2009, 03:52 PM

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