Community
    • Login

    in a list, remove all text before character

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 4 Posters 5.7k 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.
    • Furio SassiF
      Furio Sassi
      last edited by Furio Sassi

      Hi :)
      I have a big list like:

      DONNE\Ambra\2009 - Ce n’è per tutti
      DONNE\Argento Asia\1995 - De Generazione
      UOMINI\BBarboro\2004 - La spettatrice
      VIDEO\Buy Margherita\2004 - I giorni dell’abbandono

      I want remove all before the " - " for have

      Ce n’è per tutti
      De Generazione
      etc

      is possible? Many thanks :)

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Furio Sassi
        last edited by

        @Furio-Sassi

        Find: (?-s)^.*?-
        Replace: nothing
        Search mode: Regular expression

        More info: https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regular-expressions-regex-documentation

        Furio SassiF 1 Reply Last reply Reply Quote 1
        • Furio SassiF
          Furio Sassi @Alan Kilborn
          last edited by

          @Alan-Kilborn said in in a list, remove all text before character:

          (?-s)^.*?-

          Fantastic, thanks! :)

          datatraveller1D 1 Reply Last reply Reply Quote 1
          • datatraveller1D
            datatraveller1 @Furio Sassi
            last edited by

            @Alan-Kilborn I’m trying to understand why (?-s) is needed here. I think in normal cases it can be omitted and is only needed if the . matches newline checkbox is checked, isn’t it?

            Terry RT Alan KilbornA 2 Replies Last reply Reply Quote 0
            • Terry RT
              Terry R @datatraveller1
              last edited by Terry R

              @datatraveller1 said in in a list, remove all text before character:

              I’m trying to understand why (?-s) is needed here.

              Speaking for myself (but I think others will agree). When providing a solution for someone, as soon as the DOT character is involved the (?s) or (?-s) is generally the first bit of code to put on paper. It just makes good programming sense (yes regex isn’t a programming language).

              I’ve even been known to leaving it in, even when not required. It doesn’t hurt to do so.

              Terry

              1 Reply Last reply Reply Quote 2
              • Alan KilbornA
                Alan Kilborn @datatraveller1
                last edited by Alan Kilborn

                @datatraveller1

                Terry is right, but the shorter version is that it saves me from having to write my response this way:

                Find: ^.*?-
                Replace: nothing
                Search mode: Regular expression
                . matches newline checkbox: Unchecked

                As you can see, many less characters to type for me to simply use (?-s)

                BTW, for those that don’t know, if the . matches newline box is checked, it effectively puts a (?s) at the start of whatever regular expression you supply in the Find what. So if your regular expression supplied is (?-s)^.*?- it becomes (?s)(?-s)^.*?- which is really just (?-s)^.*?- because the (?-s) part “undoes” what the leading (?s) does.

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