• Login
Community
  • Login

RegEx - need to replace delimetered string with some its parts

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 3 Posters 264 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.
  • S
    Stanisław Mędrzecki
    last edited by Aug 24, 2020, 6:42 AM

    Hi,
    I have a string:
    A - B - C - D or A - B - C - D - E (the number of delimeters is changing - delimeters contains sapaces before and after “-”)

    I need to replace them with:
    B - C or sometimes C - D or D - E (if the string is shorter then E should be empty - this is optional feature) depending on my needs.

    I saw there is some quite easy formula for that, but I can’t find it.

    E 1 Reply Last reply Aug 24, 2020, 10:56 AM Reply Quote 0
    • S
      Stanisław Mędrzecki
      last edited by Aug 24, 2020, 7:58 AM

      I made something like that:
      find: (.+) - (.+) - (.+)
      replace: $2 - $3

      find have to be modified for the number of delimiters.
      Maybe there is some more universal way to do that?

      1 Reply Last reply Reply Quote 0
      • O
        Olivier Thomas
        last edited by Aug 24, 2020, 8:16 AM

        same result:
        find: .+(. - .)$
        replace: $1

        1 Reply Last reply Reply Quote 0
        • E
          Ekopalypse @Stanisław Mędrzecki
          last edited by Aug 24, 2020, 10:56 AM

          @Stanisław-Mędrzecki said in RegEx - need to replace delimetered string with some its parts:

          How do you know when to replace with B - C or sometimes C - D or D - E ?

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