+ Reply to Thread
Results 1 to 3 of 3

Using Filter() using something similar to RegEx

  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

    Using Filter() using something similar to RegEx

    I have a line that looks like this:
    Please Login or Register  to view this content.
    The trouble is, the lines I'm looking for may start as either:
    "_neighbor ..." (one beginning space) or
    "__neighbor ..." (two beginning spaces) (I had to use "_" to make it look right)

    Using RegEx, this is easy. "^_neighbor " matches the one-space line, where "^__neighbor " would match the two-space line.

    Right now, my idea is to build an array filtering on " neighbor ", then count through that array twice. The first time, I will compare left(BGPLocalAS,3) = "_ne". The second time, left(BGPLocalAS,3) = "__n".

    Is there a way to make Filter() pattern-match like RegEx does, or should I just do my twice-loop thing? There would never be more than about 20ish lines in my array.

    I think I'm looking for elegant vs brute force.
    Last edited by Rhudi; 11-25-2014 at 04:26 PM.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Using Filter() using something similar to RegEx

    Loop through twice, it'll be quicker than using Regex, not that you could with filter anyway...

  3. #3
    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

    Re: Using Filter() using something similar to RegEx

    Thanks. I currently do this:
    Please Login or Register  to view this content.
    As you might guess, I'm using this to open a "show run" router dump. I've already dealt with the limitation of Application.MAtch if my text file is too big.

    Here is how I find the correct interface (which is supposed to match a cell on my worksheet:
    Please Login or Register  to view this content.
    If you know anything about Cisco routers, you notice that looking for the interface the way I do with the bangs ("!") is silly, but for other searches I'm being consistent.

    Plus, for other things (like vrf or ip route, etc) I would use the bangs to help search for proper start/end of line hits.

    In BGP code, I might looks for "! neighbor " which is different than "! neighbor".
    In a static route, I would Filter for a gateway IP at the end of a line, similar to " 42.68.101.12!".
    If I were looking for a matching neighbor, I'd Filter for "! neighbor 42.68.101.12" or "! neighbor 42.68.101.12".

    For something like an "ip route" I Filter using the IP ending with a bang, then use a For/Next on LBound/UBound on the Filter results to match lines that start "!ip route" (and if looking for public routes, skipping "!ip route vrf".

    Instead of using ReDim, I tend to Join and array into a delimited string, the Split it back to a correctly sized array.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel 2007: Using recorder to filter is not similar to Excel 2003
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-17-2012, 05:16 AM
  2. Advanced Filter for Similar Records
    By rippledj in forum Excel General
    Replies: 3
    Last Post: 04-29-2012, 05:48 AM
  3. filter only one cell from various similar cells in a column
    By marvinlajiant in forum Excel General
    Replies: 2
    Last Post: 07-27-2011, 10:14 PM
  4. List similar to Auto-Filter's?
    By Ingeniero1 in forum Excel General
    Replies: 7
    Last Post: 07-22-2005, 03:42 PM
  5. RegEx to parse something like this...
    By R Avery in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2005, 07:06 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