• Login
Community
  • Login

Problem with converting lowercase to uppercase

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
12 Posts 5 Posters 821 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.
  • T
    Thomas 2020
    last edited by Jul 21, 2020, 4:14 PM

    I see good RegEx specialists here,
    maybe I can solve the problem here.

    I want to replace:
    Mckenzie, Mccoy, mcdonalds

    on:
    McKenzie, McCoy, McDonalds

    Find: Mc([a-z])|mc([A-z])
    Replace: Mc\u$1$2

    I’m using a different editor, and RegEx doesn’t use \u or \l there
    and it comes out like this:

    Mc￿enzie, Mc￿oy, Mc￿onalds

    Can you do it without this “\u”?

    P 1 Reply Last reply Jul 21, 2020, 5:14 PM Reply Quote 0
    • P
      PeterJones @Thomas 2020
      last edited by Jul 21, 2020, 5:14 PM

      @Pan-Jan said in Problem with converting lowercase to uppercase:

      I’m using a different editor

      This forum isn’t a generic regex help site. If you are using a different editor, ask in their forum, or find a regex help site (generic, or specific to the regex engine used by your editor).

      1 Reply Last reply Reply Quote 1
      • G
        guy038
        last edited by guy038 Jul 21, 2020, 5:29 PM Jul 21, 2020, 5:28 PM

        Hello, @pan-jan and All,

        Try this regex S/R :

        SEARCH (?i)\bMc([[:alpha:]])

        REPLACE Mc\u$1

        which changes any form, as below :

        mcDonalds
        McDonalds
        mCDonalds
        MCDonalds
        mcdonalds
        Mcdonalds
        mCdonalds
        MCdonalds
        

        with the unique good syntax :

        McDonalds
        

        Notes :

        • The (?i) in-line modifier carries the search in an insensitive way

        • The [[:alpha:]] POSIX class range represents any single uppercase or lowercase letter

        • In replacement, the \u syntax rewrites the next letter, stored in group 1, in uppercase

        BR

        guy038

        1 Reply Last reply Reply Quote 0
        • T
          Thomas 2020
          last edited by Jul 21, 2020, 6:29 PM

          @guy038 said in Problem with converting lowercase to uppercase:

          the \u syntax

          just the

          \u

          syntax doesn’t work

          1 Reply Last reply Reply Quote 0
          • G
            guy038
            last edited by Jul 21, 2020, 7:50 PM

            Hello @pan-jan and All,

            I’m really sorry but the regex syntax \u, in replacement, does do the job ! That is to say it capitalizes the first letter of the following string or group !

            For instance :

            SEARCH (?-i)foo

            REPLACE \ubar

            changes the word foo, with this exact case, by Bar

            And :

            SEARCH (?-i)(foo|bar)

            REPLACE \u$1

            would change the words foo and bar , with this exact case, by the words Foo and Bar

            Best Regards,

            guy038

            E 1 Reply Last reply Jul 21, 2020, 8:01 PM Reply Quote 0
            • E
              Ekopalypse @guy038
              last edited by Ekopalypse Jul 21, 2020, 8:02 PM Jul 21, 2020, 8:01 PM

              @guy038

              maybe you missed @PeterJones comment and OPs info?

              I’m using a different editor, and RegEx doesn’t use \u or \l there

              1 Reply Last reply Reply Quote 2
              • G
                guy038
                last edited by Jul 21, 2020, 8:08 PM

                Hi @ekopalyse,

                Ah… OK. So, what’s he waiting for to switch to Notepad++ ;-)))

                BR

                guy038

                1 Reply Last reply Reply Quote 1
                • T
                  Thomas 2020
                  last edited by Jul 21, 2020, 10:49 PM

                  @guy038 said in Problem with converting lowercase to uppercase:

                  So, what’s he waiting for to switch to Notepad++

                  Thank you but…
                  AkelPad is much better than Notepad ++.

                  1 Reply Last reply Reply Quote -1
                  • G
                    guy038
                    last edited by Jul 21, 2020, 11:14 PM

                    Hi, @pan-jan,

                    If so, why don’t you join the Akelpad community and find out a solution, from within this software, or, may be, ask the Akelpad’s author to improve the regex engine ?

                    BR

                    guy038

                    1 Reply Last reply Reply Quote 2
                    • T
                      Thomas 2020
                      last edited by Thomas 2020 Jul 22, 2020, 6:29 AM Jul 22, 2020, 6:26 AM

                      I asked before.
                      No response means nothing can be done.

                      I see there are some good RegEx specialists here
                      and I’m trying to solve the problem here.

                      1 Reply Last reply Reply Quote 0
                      • M
                        mkupper
                        last edited by mkupper Jul 22, 2020, 8:00 AM Jul 22, 2020, 7:59 AM

                        Implementation of regex varies from one application to the next.

                        It’s a guess based on the OP’s results but it seems that \u in the OP’s editor is the lead-in for Unicode related stuff such as \u0025 for a percent (%) sign. The OP’s examples have \xFFFF characters in them.

                        Fiddling with people’s names seems dangerous as there are people who have Mc… style surnames where the third character is not upper-case. If there is a requirement to make the names a consistent case then convert everything to upper case.

                        I think we are in https://community.notepad-plus-plus.org/topic/15958/faq-desk-you-ve-asked-your-question-in-the-wrong-place territory.

                        1 Reply Last reply Reply Quote 2
                        • T
                          Thomas 2020
                          last edited by Jul 22, 2020, 12:59 PM

                          @mkupper said in Problem with converting lowercase to uppercase:

                          as there are people who have Mc… style surnames where the third character is not upper-case

                          e.g?

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