Community

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

    Replace text

    Help wanted · · · – – – · · ·
    3
    8
    112
    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.
    • Craig McFarlane
      Craig McFarlane last edited by

      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
      • astrosofista
        astrosofista last edited by astrosofista

        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
        • Craig McFarlane
          Craig McFarlane last edited by

          @astrosofista said in Replace text:

          overlay0_overlay = \K".+?"

          Thank you so much. Perfect and worked a treat.

          1 Reply Last reply Reply Quote 0
          • Craig McFarlane
            Craig McFarlane last edited by

            @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.

            astrosofista 1 Reply Last reply Reply Quote 0
            • Terry R
              Terry R last edited by Terry R

              @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
              • astrosofista
                astrosofista @Craig McFarlane last edited by

                @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
                • Craig McFarlane
                  Craig McFarlane last edited by

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

                  astrosofista 1 Reply Last reply Reply Quote 0
                  • astrosofista
                    astrosofista @Craig McFarlane last edited by

                    @Craig-McFarlane

                    Glad it worked. Thank you for report it back.

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