Community
    • Login

    How do I add a specific text at the end of each line start with same specific text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 246 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.
    • Khoa LeK
      Khoa Le
      last edited by

      Hi,

      I have something like this
      FLEXGRP_BA01
      FLEXGRP_CN08
      FLEXGRP_CR8765
      FLEXGRP_ZN760

      and replace with this

      FLEXGRP_BA01_FLEXGRP
      FLEXGRP_CN08_FLEXGRP
      FLEXGRP_CR8765_FLEXGRP
      FLEXGRP_ZN760_FLEXGRP

      I have tried using syntax below but it doesn’t work
      Find: (?-si)^FLEXGRP_.+
      Replace with: $0_FLEXGRP

      Your help would be greatly appreciated. Thank you!

      Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 2
      • Alan KilbornA
        Alan Kilborn @Khoa Le
        last edited by Alan Kilborn

        @Khoa-Le

        You are actually amazingly close.
        Simply put braces around your 0 in your replacement, i.e., ${0}

        1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones @Khoa Le
          last edited by

          @Khoa-Le ,

          Thank you for the before and after data, and showing what you tried. That’s appreciated.

          Unfortunately, when I try what you showed, it worked for me.

          00b46dc3-7232-4858-b6d2-8a2812e2365c-image.png

          @Alan-Kilborn – his worked for me without edits, without the braces. Though I agree that braces are a better idea, to avoid problems.

          FLEXGRP_BA01
          FLEXGRP_CN08
          FLEXGRP_CR8765
          FLEXGRP_ZN760
          

          became

          FLEXGRP_BA01_FLEXGRP
          FLEXGRP_CN08_FLEXGRP
          FLEXGRP_CR8765_FLEXGRP
          FLEXGRP_ZN760_FLEXGRP
          

          You’re already following most of the advice below, but I’m showing it because </> would help make sure there isn’t a forum-special character in your data (like I showed above)… and it’s a good reminder for everyone

          ----

          Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as plain text using the </> toolbar button or manual Markdown syntax. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get… Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

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

            @PeterJones said in How do I add a specific text at the end of each line start with same specific text:

            his worked for me without edits, without the braces. Though I agree that braces are a better idea, to avoid problems.

            Ha. I didn’t even try the original replacement string.
            It isn’t often that we get a request where someone actually has it right at the time of asking!

            I thought there was something special about 0, and you’re right, I just always err on the side of caution and do ${0}, ${1}, etc. I guess the special thing I’m thinking of about 0 is that you can’t do \0 like you can \1, \2, etc.

            Aside: Most people like the \1 notation because it is shorter than ${1} but I like the cleaner look of the latter, and “leaning toothpicks” make me crazy as well.

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