• Login
Community
  • Login

Upper case letter in replace

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 3 Posters 352 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.
  • H
    Hakunamatata67
    last edited by Hakunamatata67 Jun 11, 2020, 11:45 AM Jun 11, 2020, 11:44 AM

    Hi,

    I have many documents to translate. So I opened them in NP++ and replace many words at one time with ‘Replace in all opened documents’.

    For example: I want to translate “dog” to “chien” (in french). If it’s “Dog”, I want it replace to “Chien”.
    If I check “Preserve case”, it only replaces the first one, not the one with with the first letter in capital (Dog).

    Is there any way to replace the words in both situation without having to retype the same twice (one in lower case and one with first letter in capital)?

    E 1 Reply Last reply Jun 11, 2020, 12:12 PM Reply Quote 0
    • E
      Ekopalypse @Hakunamatata67
      last edited by Jun 11, 2020, 12:12 PM

      @Hakunamatata67

      use regular expression search mode and check match case (I guess that what you translated to preserve case).

      find what:(?:(d)|(D))og
      replace with: (?1c)(?2C)hien

      1 Reply Last reply Reply Quote 4
      • G
        guy038
        last edited by Jun 11, 2020, 4:56 PM

        Hello, @Hakunamatata67, @ekopalypse and All,

        An other syntax could be :

        SEARCH (?-i)(?:(D)|d)og    or more simply    (?-i)(Dog)|dog

        REPLACE (?1\u)chien

        Best regards,

        guy038

        1 Reply Last reply Reply Quote 4
        • H
          Hakunamatata67
          last edited by Jun 15, 2020, 7:01 AM

          Thank you guys :)

          1 Reply Last reply Reply Quote 0
          • H
            Hakunamatata67
            last edited by Jun 15, 2020, 7:27 AM

            I have an issue: if I replace “he” to “il” (in french), it will also replace all word containing “he”, for example, it will replace “other” to “otilr”.
            Any way to avoid that?

            1 Reply Last reply Reply Quote 0
            • G
              guy038
              last edited by guy038 Jun 15, 2020, 5:20 PM Jun 15, 2020, 8:42 AM

              Hi, @Hakunamatata67, @ekopalypse and All,

              Ah yes, I should have been more specific ! So, my regexes become :

              SEARCH (?-i)\b(?:(D)|d)og\b    or     (?-i)\b(?:(Dog)|dog)\b

              REPLACE (?1\u)chien

              And, if you prefer the @ekopalypse’s syntax :

              find what:\b(?:(d)|(D))og\b
              replace with: (?1c)(?2C)hien


              • The \b is an assertion which represents a zero-length location between, both :

                • A non-word character and a word character

                • A word character and a non-word character

              • The conditional (?#Test) structure, in replacement, rewrites the word Test if the group # has been matched in search regex

              Best Regards

              guy038

              1 Reply Last reply Reply Quote 3
              • H
                Hakunamatata67
                last edited by Jun 15, 2020, 12:28 PM

                You’re the best guy038!
                Thank you so much

                Take care

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