• Login
Community
  • Login

in a list, remove all text before character

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 4 Posters 6.2k 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.
  • F
    Furio Sassi
    last edited by Furio Sassi Nov 20, 2022, 2:28 PM Nov 20, 2022, 2:28 PM

    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 :)

    A 1 Reply Last reply Nov 20, 2022, 2:48 PM Reply Quote 0
    • A
      Alan Kilborn @Furio Sassi
      last edited by Nov 20, 2022, 2:48 PM

      @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

      F 1 Reply Last reply Nov 20, 2022, 4:34 PM Reply Quote 1
      • F
        Furio Sassi @Alan Kilborn
        last edited by Nov 20, 2022, 4:34 PM

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

        (?-s)^.*?-

        Fantastic, thanks! :)

        D 1 Reply Last reply Nov 20, 2022, 6:30 PM Reply Quote 1
        • D
          datatraveller1 @Furio Sassi
          last edited by Nov 20, 2022, 6:30 PM

          @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?

          T A 2 Replies Last reply Nov 20, 2022, 6:49 PM Reply Quote 0
          • T
            Terry R @datatraveller1
            last edited by Terry R Nov 20, 2022, 6:50 PM Nov 20, 2022, 6:49 PM

            @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
            • A
              Alan Kilborn @datatraveller1
              last edited by Alan Kilborn Nov 20, 2022, 9:04 PM Nov 20, 2022, 7:10 PM

              @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
              3 out of 6
              • First post
                3/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors