Community
    • Login

    Replace text between 2 characters

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 4.9k 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.
    • Comic Sans Criminal2C
      Comic Sans Criminal2
      last edited by

      Hello,

      I want to replace all the text in my text file with a certain thing

      For example, if we take the text:

      John sat on the mat and said"the fat cat ate the rat"and matt said"what about a bat"presumptuously.

      I want to make it so the text between the each group of speech marks is replaced with the exact same thing except with spaces at the start and end.

      John sat on the mat and said “the fat cat ate the rat” and matt said “what about a bat” presumptuously.

      Of course, the text file is much larger and I would hate to go through it all doing this manually.

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by guy038

        Hello, @comic_sans-criminal2 and All,

        No problem ! But I noticed that your “Before” text contained regular Quotation Marks ( \x{0022} ), whereas your “After” text contained Left Double Quotation Marks ( \x{201C} ) and Right double quotation marks ( \x{201D} )

        Refer to http://www.unicode.org/charts/PDF/U2000.pdf

        Anyway, the regex S/R , below, will match three 3 characters !


        So :

        • Open the Replace panel ( Ctrl + H )

        • Select the Regular expression search mode

        • Tick the Wrap around option

        • Type (?-s)["“](.+?)["”] , in the Find what: zone

        • And, in the Replace with zone :

          • Write \x20"\1"\x20 , if you need regular quotation marks

          • Use, instead, \x20“\1”\x20 , if you prefer stylistic quotation marks

        • Click on the Replace All button

        Voilà !

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 0
        • Comic Sans Criminal2C
          Comic Sans Criminal2
          last edited by

          @guy038 said:

          \x20"\1"\x20

          Nice! This was exactly what I was looking for, thank you very much

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