Java Make First Letter Of Each Word In Uppercase

Chapter: Regular Expression Last Updated: 13-09-2016 17:10:39 UTC

Program:

            /* ............... START ............... */
                
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JavaMadeUpperCase {

	public static void main(String[] args) {
		
		String str = "welcome to javascan.com";
		System.out.println(str);
		StringBuffer stringbf = new StringBuffer();
		Matcher m = Pattern.compile("([a-z])([a-z]*)", Pattern.CASE_INSENSITIVE).matcher(str);
		while (m.find()) {
			m.appendReplacement(stringbf, m.group(1).toUpperCase() + m.group(2).toLowerCase());
		}
		System.out.println(m.appendTail(stringbf).toString());
	}
}
                /* ............... END ............... */
        

Output

welcome to javascan.com
Welcome To Javascan.Com

Tags

Make First Letter Of Each Word In Uppercase, Java, Regular Expression, Using toUpperCase(), appendTail() methods

Similar Programs Chapter Last Updated
Java Regular Expression Match Single Digit Regular Expression 15-12-2016
Java Regular Expression To Check Number With Dot Separator And Two Decimal Regular Expression 14-12-2016
Java Regular Expression To Check Numeric Regular Expression 14-12-2016
Java Regular Expression Digit Only Regular Expression 14-12-2016
Java Check Date Format Example Regular Expression 14-09-2016
Java Validate email Address Regular Expression 13-09-2016
Java Replace All Occourances Of String Example Regular Expression 13-09-2016
Java Match Phone Numbers Using Regular Expression Regular Expression 11-09-2016
Java Last Index Of Word Using Regular Expression Regular Expression 11-09-2016
Java Find Word Occurrence Using Regular Expression Regular Expression 11-09-2016
Java Splitting String Using Regular Expression Regular Expression 11-09-2016
Java Regex Pattern Split Example Regular Expression 21-06-2016
IP Address From String In Java Regex Regular Expression 21-07-2016
Validate UserName Using Regular Expression In Java Regular Expression 22-09-2018
Java Regex IP Address Example Regular Expression 21-07-2016
Regular Expression In Java Example Regular Expression 09-07-2016
Pattern Matching In Java Example Regular Expression 09-07-2016

1