<html> <head> <title>首字母全改为大写JS脚</title> <SCRIPT LANGUAGE="JavaScript"> function changeCase(frmObj) { var index; var tmpStr; var tmpChar; var preString; var postString; var strlen; tmpStr = frmObj.value.toLowerCase(…
上周看到大家在JS群讨论如何把一句英文句子单词收割字母大写,大家都说用正则简单,对于正则还是有点模糊,于是乎自己敲了下 //面试题:如何把一句英文每个单词首字母大写? var str="what fuck is 1235 going on ?"; var arr=str.split(" "); for(var i=0,newArr=[],sumArr=[];i<arr.length;i++){ var news=arr[i][0].toUpperCase();…
string.capwords() 将每个单词首字母大写 代码: import string s = ' The quick brown fox jumped over the lazy dog. ' print s print string.capwords(s) 结果: The quick brown fox jumped over the lazy dog. The Quick Brown Fox Jumped Over The Lazy Dog. 请按任意键继续. . . string模…
还有其他一些(隐性)要求(要不然无法通过测试): .如果首字母已经大写,则不用变 .不是英文字母的不变 e.g. Input: hello world! this is _Ljj speaking! Output: Hello World! This Is _ljj Speaking! 思路写在注释里面了 /* Input a string * Output: uppercase the first character of evrey word * if already uppercased,…