• Login
Community
  • Login

Replace text

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 3 Posters 470 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.
  • C
    Craig McFarlane
    last edited by Mar 22, 2020, 10:59 PM

    Hi Guys.

    I have about 1000 files in a directory. I am looking to search through all of them as all of them will have the line below. However the text in between the. " " will be different. I am looking to replace what ever is in-between the " " with for example new.png

    overlay0_overlay = “6-Pak (USA).png”

    Can anyone help with the find a replace syntax to do that please.

    Many thanks in advance.

    1 Reply Last reply Reply Quote 0
    • A
      astrosofista
      last edited by astrosofista Mar 22, 2020, 11:19 PM Mar 22, 2020, 11:17 PM

      Hi:

      Please back-up your files and try the following S/R regex:

      Search:    overlay0_overlay = \K".+?"
      Replace:   "new.png"
      

      Hope this helps.

      1 Reply Last reply Reply Quote 2
      • C
        Craig McFarlane
        last edited by Mar 22, 2020, 11:23 PM

        @astrosofista said in Replace text:

        overlay0_overlay = \K".+?"

        Thank you so much. Perfect and worked a treat.

        1 Reply Last reply Reply Quote 0
        • C
          Craig McFarlane
          last edited by Mar 23, 2020, 12:00 AM

          @astrosofista said in Replace text:

          overlay0_overlay = \K".+?"

          Actually. Sorry. I thought this has worked but it seems to not change the text. Any other suggestions? thanks in advance.

          A 1 Reply Last reply Mar 23, 2020, 12:29 AM Reply Quote 0
          • T
            Terry R
            last edited by Terry R Mar 23, 2020, 12:24 AM Mar 23, 2020, 12:22 AM

            @Craig-McFarlane said in Replace text:

            eems to not change the text

            It’s possible the quotes you supplied and shown in the post above may not be the actual ones in the text file. Suggest copy the ones from the file, replacing the ones in the regex (regular expression) you used.

            Alternatively, copy the entire portion of one instance you want to replace, then change all the text between the quotes to the one in the regex. You will also need to add the \K portion as shown in the regex. Hopefully you understand my idea.

            Terry

            1 Reply Last reply Reply Quote 1
            • A
              astrosofista @Craig McFarlane
              last edited by Mar 23, 2020, 12:29 AM

              @Craig-McFarlane

              Maybe this is the problem. I have assumed that the files to be changed uses strings with regular quote marks, as in “”, instead of “curly quotes”, because quoted text get changed into smart quotes when being posted to this forum. Please check that the S/R regex and your data use the same kind of quotes.

              If this advice does not resolve the problem, please post examples of the offending text.

              1 Reply Last reply Reply Quote 2
              • C
                Craig McFarlane
                last edited by Mar 23, 2020, 8:31 AM

                Thanks mate. Apologies what you did give me originally did in fact work. I was looking at the wrong copy of the data.

                A 1 Reply Last reply Mar 25, 2020, 7:03 PM Reply Quote 0
                • A
                  astrosofista @Craig McFarlane
                  last edited by Mar 25, 2020, 7:03 PM

                  @Craig-McFarlane

                  Glad it worked. Thank you for report it back.

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