#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2016
    Posts
    1
    Rep Power
    0

    Filtering lines with more than 4 backslashes


    Hi, how can I filter out lines with more than 4 backslashes with regex? E.g.

    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{20C62CA0-15DA-101B-B9A8-444553540000}
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{20C62CA0-15DA-101B-B9A8-444553540000}\Control]

    Only the first one should remain.
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,334
    Rep Power
    9645
    Do what seems most obvious, but remember to escape the backslashes at least once.
    Code:
    .*\\.*\\.*\\.*\\.*\\
    If you want to be more efficient then
    Code:
    [^\\]*\\[^\\]*\\[^\\]*\\[^\\]*\\[^\\]*\\

IMN logo majestic logo threadwatch logo seochat tools logo