• Login
Community
  • Login

[REGEX] Remove a section from a list.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 3 Posters 2.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    Dafuq Xerath
    last edited by Dafuq Xerath Jan 25, 2017, 7:43 AM Jan 25, 2017, 7:41 AM

    Hey =)
    i have a big list of clan members, everything is like:

    CLANNAME:NICKNAME:EMAIL@EMAIL221.COM :DATE:YES/NO
    CLANNAME:NICKNAME:EMAIL@EMAIL233.COM :DATE:YES/NO
    CLANNAME:NICKNAME:EMAIL@EMAIL334.COM :DATE:YES/NO
    CLANNAME:NICKNAME:EMAIL@EMAIL554.COM :DATE:YES/NO

    I just want now to remove the “@Email.com” part in the whole list. From @ to the next : can anything be deleted. Problem is, there are many different email providers, so i cant just replace every one :-/. But i need the Email Name to generate a tournament Email just not the “@EmailProvider.com”
    Help would be amazing.

    1 Reply Last reply Reply Quote 0
    • A
      abelfourier
      last edited by abelfourier Jan 25, 2017, 7:55 AM Jan 25, 2017, 7:55 AM

      @(?:[^.]+)\.COM #case insensitive

      1 Reply Last reply Reply Quote 1
      • G
        guy038
        last edited by Jan 25, 2017, 6:55 PM

        Hello, Dafug Xerath,

        Just to show that several regexes can achieve the same S/R, here is a second solution :

        • Open your file in Notepad++

        • Open the Replace dialog ( CTRL + H )

        • In the Find what: field, type in @(?:.+?)(?=:)

        • Leave the Replace with: EMPTY

        • Select the Regular expression search mode

        • Finally, click on the Replace All button

        Et voilà !

        NOTES :

        • This regex looks, first, for the literal character @.

        • At the end of the regex, the part (?=:), called a look-ahead, is a condition, that means that the overall match must be followed by a literal colon :.

        • So, the inner middle part, .+?, tries to match the shortest range of any character between the @ character, included and the : character, excluded.

        • The symbol + is a quantifier that means a maximum of characters, from 1 to n and the symbol ?, after the quantifier +, forces the regex engine to select the minimum range of any character, between the limits @ and :

        • As this range of characters is included in the syntax (?: .... ), this means that the range, of each line, will NOT be stored for later use, either in the Find or Replace regexes.

        • Finally, as the Replace dialog is empty, this range is just deleted, from each line !


        Beware : if you prefer to use the abelfourier’s search regex, the correct regex is, obviously :

        @(?:[^.]+)\.COM

        You’ll have to uncheck the Match case option

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 0
        2 out of 3
        • First post
          2/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors