Thread: Capitilizing first letter

Results 1 to 6 of 6
  1. #1 Capitilizing first letter 
    Seven Lions

    Yvne's Avatar
    Join Date
    Sep 2012
    Posts
    1,204
    Thanks given
    164
    Thanks received
    173
    Rep Power
    81
    Hey I made it so your first letter is always capital when you type but how do I make it so if you use shift for the first letter it will make it capital but not the second letter.

    cause that's what it keeps doing.

    basically if I do shift for a word like this: HuGe

    it will make it: HuGE

    it makes the leter after the shift capital to.




    Code:
    public static String capitalize(String s) {
    		for (int i = 0; i < s.length(); i++) {
    			if (i == 0) {
    				s = String.format( "%s%s",
                             Character.toUpperCase(s.charAt(0)),
                             s.substring(1) );
    			}
    			if (!Character.isLetterOrDigit(s.charAt(i))) {
    				if (i + 1 < s.length()) {
    					s = String.format( "%s%s%s",
                                 s.subSequence(0, i+1),
                                 Character.toUpperCase(s.charAt(i + 1)),
                                 s.substring(i+2) );
    				}
    			}
    		}
    		return s;
    	}
    Code:
    public static void method526(String s, Stream stream)
    	    {
    		if(s.length() > 80)
    	            s = s.substring(0, 80);
    	        //s = s.toLowerCase();
    	        int i = -1;
    	        for(int j = 0; j < s.length(); j++)
    	        {
    	            char c = s.charAt(j); 
    			 int k = 0;
    	            for(int l = 0; l < validChars.length; l++)
    	            {
    	                if(c != validChars[l])
    	                    continue;
    	                k = l;
    	                break;
    	            }
    	                stream.writeWordBigEndian(k);//sending to server
    	        }
    	    }
    Thanks!
    Reply With Quote  
     

  2. #2  
    Super Donator


    Join Date
    Jun 2007
    Age
    31
    Posts
    2,157
    Thanks given
    316
    Thanks received
    282
    Rep Power
    779
    How are you capitalizing it
    Reply With Quote  
     

  3. #3  
    Seven Lions

    Yvne's Avatar
    Join Date
    Sep 2012
    Posts
    1,204
    Thanks given
    164
    Thanks received
    173
    Rep Power
    81
    Quote Originally Posted by HcoJustin View Post
    How are you capitalizing it
    I did this a long time ago i just noticed it did that? do you know the method i would need to look for or the java file?
    Reply With Quote  
     

  4. #4  
    Super Donator


    Join Date
    Jun 2007
    Age
    31
    Posts
    2,157
    Thanks given
    316
    Thanks received
    282
    Rep Power
    779
    If you only want the first letter, not after every punctuation:
    Code:
    Character.toUpperCase(input.charAt(0)) + input.substring(1)
    Reply With Quote  
     

  5. #5  
    Seven Lions

    Yvne's Avatar
    Join Date
    Sep 2012
    Posts
    1,204
    Thanks given
    164
    Thanks received
    173
    Rep Power
    81
    Quote Originally Posted by HcoJustin View Post
    How are you capitalizing it
    I guess this is it then

    Code:
    	public static String capitalize(String s) {
    		for (int i = 0; i < s.length(); i++) {
    			if (i == 0) {
    				s = String.format( "%s%s",
                             Character.toUpperCase(s.charAt(0)),
                             s.substring(1) );
    			}
    			if (!Character.isLetterOrDigit(s.charAt(i))) {
    				if (i + 1 < s.length()) {
    					s = String.format( "%s%s%s",
                                 s.subSequence(0, i+1),
                                 Character.toUpperCase(s.charAt(i + 1)),
                                 s.substring(i+2) );
    				}
    			}
    		}
    		return s;
    	}
    Reply With Quote  
     

  6. #6  
    Seven Lions

    Yvne's Avatar
    Join Date
    Sep 2012
    Posts
    1,204
    Thanks given
    164
    Thanks received
    173
    Rep Power
    81
    Quote Originally Posted by HcoJustin View Post
    If you only want the first letter, not after every punctuation:
    Code:
    Character.toUpperCase(input.charAt(0)) + input.substring(1)
    no I want to be able to capitalize any letter if I use shift.
    I just don't want it to capitalize the second one when i'm holding shift for the first letter.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Capitalizing first letter in yell
    By Beanerrr in forum Help
    Replies: 9
    Last Post: 03-15-2011, 09:21 PM
  2. Replies: 2
    Last Post: 12-13-2010, 09:58 AM
  3. Capitilizing "+playerName+" First Letter.
    By ByteBlast in forum Help
    Replies: 2
    Last Post: 11-05-2010, 04:21 AM
  4. [508] Capitalizing the First letter in a Username.
    By ServerSoft in forum Snippets
    Replies: 3
    Last Post: 01-24-2010, 05:06 AM
  5. Replies: 10
    Last Post: 11-14-2009, 11:08 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •