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. Case Conversion Regular Expression in JAVA 8

Case Conversion Regular Expression in JAVA 8

Scheduled Pinned Locked Moved Regular Expressions
regextutorialjavaperlquestion
4 Posts 2 Posters 0 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

    Hi Community, I have come to the conclusion that it may not to be possible to change the case of a string in JAVA 8 as simply as it is to change the case in say Perl. However, before I move on, I just wanted to have someone on this forum confirm its not possible to change the case in JAVA 8 as follows: Insert the whole regex match or the 1st through 99th backreference with the first letter of each word in the matched text converted to uppercase and the remaining letters converted to lowercase. Example Replacing .+ with \I0 in HeLlO WoRlD yields Hello World Can someone confirm that the above isn't possible with JAVA 8? If its not possible, can someone let me know how to achieve the above with JAVA 8? Thanks

    L 1 Reply Last reply
    0
    • U User 13540679

      Hi Community, I have come to the conclusion that it may not to be possible to change the case of a string in JAVA 8 as simply as it is to change the case in say Perl. However, before I move on, I just wanted to have someone on this forum confirm its not possible to change the case in JAVA 8 as follows: Insert the whole regex match or the 1st through 99th backreference with the first letter of each word in the matched text converted to uppercase and the remaining letters converted to lowercase. Example Replacing .+ with \I0 in HeLlO WoRlD yields Hello World Can someone confirm that the above isn't possible with JAVA 8? If its not possible, can someone let me know how to achieve the above with JAVA 8? Thanks

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

      I suggested to you last week that it would be easier to use string functions to do what you want. Convert the entire string to lower case, then find each word beginning and convert the single letter to upper case.

      U 2 Replies Last reply
      0
      • L Lost User

        I suggested to you last week that it would be easier to use string functions to do what you want. Convert the entire string to lower case, then find each word beginning and convert the single letter to upper case.

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

        Hey Richard, I was so fixated with the way I wanted to achieve the result that I didn't realise how easy it is to get the result using your suggestion. TBH, with your suggestion I can get the result just using SQL, converting the entire string to lower case (as you suggested) and using a simple SQL function (which I'm familiar with) to Capitalize each word. I literally would have saved myself 9 hours of trying to figure this out. Thanks man

        1 Reply Last reply
        0
        • L Lost User

          I suggested to you last week that it would be easier to use string functions to do what you want. Convert the entire string to lower case, then find each word beginning and convert the single letter to upper case.

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

          Thanks man

          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