Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. Regular Expression to Change Uppercase Text to Lowercase

Regular Expression to Change Uppercase Text to Lowercase

Scheduled Pinned Locked Moved Regular Expressions
regextutorial
13 Posts 2 Posters 2 Views 1 Watching
  • 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.
  • U Offline
    U Offline
    User 13540679
    wrote on last edited by
    #1

    Can someone assist with a regular expression that will replace and capitalize the first character in a text characters to lowercase For example PETER Before Peter After JohN Before John After paul Before Paul After The following Regex will locate the Uppercase characters [A-Z] But I don't know how to replace them by turning the first character to Uppercase. Thanks

    L 2 Replies Last reply
    0
    • U User 13540679

      Can someone assist with a regular expression that will replace and capitalize the first character in a text characters to lowercase For example PETER Before Peter After JohN Before John After paul Before Paul After The following Regex will locate the Uppercase characters [A-Z] But I don't know how to replace them by turning the first character to Uppercase. Thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You are probably better off using one of the many methods available with the String type. But since you have not identified which language you are using, that is something of a guess.

      U 1 Reply Last reply
      0
      • U User 13540679

        Can someone assist with a regular expression that will replace and capitalize the first character in a text characters to lowercase For example PETER Before Peter After JohN Before John After paul Before Paul After The following Regex will locate the Uppercase characters [A-Z] But I don't know how to replace them by turning the first character to Uppercase. Thanks

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        In C# (for example) there is no "proper case": one changes to "lower case", then uses "title case". [TextInfo.ToTitleCase(String) Method (System.Globalization) | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.textinfo.totitlecase?view=net-5.0)

        Quote:

        Converts the specified string to title case (except for words that are entirely in uppercase, which are considered to be acronyms).

        It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

        U 1 Reply Last reply
        0
        • L Lost User

          You are probably better off using one of the many methods available with the String type. But since you have not identified which language you are using, that is something of a guess.

          U Offline
          U Offline
          User 13540679
          wrote on last edited by
          #4

          Hi, Thanks for reaching out. Sorry for not mentioning the language. The language is JAVA 8

          L 1 Reply Last reply
          0
          • L Lost User

            In C# (for example) there is no "proper case": one changes to "lower case", then uses "title case". [TextInfo.ToTitleCase(String) Method (System.Globalization) | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.textinfo.totitlecase?view=net-5.0)

            Quote:

            Converts the specified string to title case (except for words that are entirely in uppercase, which are considered to be acronyms).

            It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

            U Offline
            U Offline
            User 13540679
            wrote on last edited by
            #5

            Thanks getting in touch. I'm using Java 8 Are you able help?

            1 Reply Last reply
            0
            • U User 13540679

              Hi, Thanks for reaching out. Sorry for not mentioning the language. The language is JAVA 8

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              See String (Java Platform SE 7 )[^].

              U 1 Reply Last reply
              0
              • L Lost User

                See String (Java Platform SE 7 )[^].

                U Offline
                U Offline
                User 13540679
                wrote on last edited by
                #7

                Hi Richard, Thanks for reaching out. And thanks for the link. Unfortunately, I'm extremely new to Regex so unfortunately I wouldn't know where to look in the link String (Java Platform SE 7 )[^] I thought this was a pretty easy question for someone help with an answer to?

                L 1 Reply Last reply
                0
                • U User 13540679

                  Hi Richard, Thanks for reaching out. And thanks for the link. Unfortunately, I'm extremely new to Regex so unfortunately I wouldn't know where to look in the link String (Java Platform SE 7 )[^] I thought this was a pretty easy question for someone help with an answer to?

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  The String class has nothing to do with Regexes. You use it to quickly convert all characters to lower case. You can then find some method to capitalise the first letter of each word.

                  U 1 Reply Last reply
                  0
                  • L Lost User

                    The String class has nothing to do with Regexes. You use it to quickly convert all characters to lower case. You can then find some method to capitalise the first letter of each word.

                    U Offline
                    U Offline
                    User 13540679
                    wrote on last edited by
                    #9

                    Hi Richard, Sorry to be pain, but could please provide an example

                    L 1 Reply Last reply
                    0
                    • U User 13540679

                      Hi Richard, Sorry to be pain, but could please provide an example

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      I have a better idea. Think about what you are trying to do and work out which methods are likely to help you. You will learn far more by trying things yourself.

                      U 3 Replies Last reply
                      0
                      • L Lost User

                        I have a better idea. Think about what you are trying to do and work out which methods are likely to help you. You will learn far more by trying things yourself.

                        U Offline
                        U Offline
                        User 13540679
                        wrote on last edited by
                        #11

                        ok, I will think of something. I will post it. Hopefully, you'll let me know if I'm on the right track

                        1 Reply Last reply
                        0
                        • L Lost User

                          I have a better idea. Think about what you are trying to do and work out which methods are likely to help you. You will learn far more by trying things yourself.

                          U Offline
                          U Offline
                          User 13540679
                          wrote on last edited by
                          #12

                          I'm never going to figure it out! Can I get some hints on a solution?

                          1 Reply Last reply
                          0
                          • L Lost User

                            I have a better idea. Think about what you are trying to do and work out which methods are likely to help you. You will learn far more by trying things yourself.

                            U Offline
                            U Offline
                            User 13540679
                            wrote on last edited by
                            #13

                            So, this is my attempt I tried the following regex in Java 8, (?i)(Helló) (Wórld) which matches HeLlÓ WóRlD the replacement string \U$1 \L$2 should become HELLÓ wórld, but it doesn't work. Can someone please help me???

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups