xxxxxxxxxx
if (this.state.name[0] >= 'A' && this.state.name[0] <= 'Z')
this.setState({ name: "First letter is uppercase" })
else
this.setState({ name: "First letter is NOT uppercase" })
}
xxxxxxxxxx
/**** Check if First Letter Is Upper Case in JavaScript***/
function startsWithCapital(word){
return word.charAt(0) === word.charAt(0).toUpperCase()
}
console.log(startsWithCapital("Hello")) // true
console.log(startsWithCapital("hello")) // false
xxxxxxxxxx
var str = "hello world";
str = str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.toUpperCase();
});
alert(str); //Displays "Hello World"
xxxxxxxxxx
>>> "hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'
xxxxxxxxxx
public static void main(String[] args)
{
System.out.println("Enter name");
Scanner kb = new Scanner (System.in);
String text = kb.next();
if ( null == text || text.isEmpty())
{
System.out.println("Text empty");
}
else if (text.charAt(0) == (text.toUpperCase().charAt(0)))
{
System.out.println("First letter in word "+ text + " is upper case");
}
}