Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Replace pattern not working correctly

    Help wanted · · · – – – · · ·
    2
    3
    50
    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.
    • Brennan OBrien
      Brennan OBrien last edited by

      Hi again all – I was so proud of myself I was able to correctly select a block of text, but I’m not being able to do the replacement command correctly, so I’m sure my selection is wrong in some way. Here’s my starting text (and I have lots of these to do in the file):

            Derro Maniac
      

      The text is exactly 6 spaces (important, because I have other text with exactly 4 spaces I need to get rid of after I have this piece solved).

      My target outcome would look like this:

      ###
      Derro Maniac
      

      I’ve been able to successfully select the text using the following search string (regex).

      (?<=\x20{6}).*$
      

      But when I try to replace using this replace string, my original text is getting wiped out.

      ###\r\n\1
      

      I get this result:

            ###
      
      

      What am I doing wrong?

      Thanks!

      Alan Kilborn 1 Reply Last reply Reply Quote 0
      • Alan Kilborn
        Alan Kilborn @Brennan OBrien last edited by

        @Brennan-OBrien said in Replace pattern not working correctly:

        Try ###\r\n${0} as your replace string.

        But if you really want to know what is wrong with your replace string, I’ll tell you that you are trying to insert “group 1” (with your use of \1), but you have no group 1 captured in the find string.

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

          You could obtain a group one in your find string by changing it to: (?<=\x20{6})(.*)$

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          Copyright © 2014 NodeBB Forums | Contributors