• Login
Community
  • Login

Replace text inside Quotations

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 2 Posters 494 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.
  • G
    geeman72
    last edited by Mar 20, 2023, 12:46 PM

    Hello,

    I am struggling to find an answer to my problem.

    I have a large text file that has lots of strings similar to the below:-

    translation=“-56.3568 13.54 94.6262”
    translation=“116.799 17.376 -142.61”
    translation=“38.3606 5.67512 204.685”

    Each middle number inside the quotes is different but I want them to read all the same, like this:-

    translation=“-56.3568 10.2 94.6262”
    translation=“116.799 10.2 -142.61”
    translation=“38.3606 10.2 204.685”

    Is that even possible with Notepad++?

    Many thanks,

    Greeham

    A G 2 Replies Last reply Mar 20, 2023, 1:07 PM Reply Quote 0
    • A
      Alan Kilborn @geeman72
      last edited by Alan Kilborn Mar 20, 2023, 1:09 PM Mar 20, 2023, 1:07 PM

      @geeman72 said in Replace text inside Quotations:

      translation=“-56.3568 13.54 94.6262”
      translation=“116.799 17.376 -142.61”
      translation=“38.3606 5.67512 204.685”

      A quick one that is not entirely rigorous, but fits your data:

      Find: ([\d.-]+) [\d.-]+ ([\d.-]+)
      Replace: ${1} 10.2 ${2}
      Search mode: Regular expression

      More relevant info:

      • https://community.notepad-plus-plus.org/topic/21925/faq-desk-formatting-forum-posts

      • https://community.notepad-plus-plus.org/topic/22022/faq-desk-template-for-search-replace-questions

      • https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regular-expressions-regex-documentation

      1 Reply Last reply Reply Quote 1
      • G
        geeman72 @geeman72
        last edited by Mar 20, 2023, 1:13 PM

        That’s great thank you, one other question if I might, I forgot to mention there are other strings that are made up of 3 sets of numbers as well but don’t want those changing, so would I add the search to include the word translation at the beginning as well?

        Thanks for the help,

        Greeham

        A 1 Reply Last reply Mar 20, 2023, 1:18 PM Reply Quote 1
        • A
          Alan Kilborn @geeman72
          last edited by Mar 20, 2023, 1:18 PM

          @geeman72 said in Replace text inside Quotations:

          so would I add the search to include the word translation at the beginning as well?

          Certainly!

          G 1 Reply Last reply Mar 20, 2023, 1:27 PM Reply Quote 0
          • G
            geeman72 @Alan Kilborn
            last edited by Mar 20, 2023, 1:27 PM

            @Alan-Kilborn Great thanks.

            I have managed it with some additional searching (since I am a new noobie) and worked with this:-

            Find: (?-s)(.+?translation=")([\d.-]+) [\d.-]+ ([\d.-]+)
            Replace: ${1}${2} 99.403 ${3}
            Search mode: Regular expression

            Thanks again,

            Greeham

            A 1 Reply Last reply Mar 20, 2023, 1:29 PM Reply Quote 3
            • A
              Alan Kilborn @geeman72
              last edited by Mar 20, 2023, 1:29 PM

              @geeman72 said in Replace text inside Quotations:

              and worked with this

              Seems reasonable!

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