可以把文章标题中的英文单词的首字母变成大写的函数
来源:互联网 发布:魔兽数据库手机版7.25 编辑:程序博客网 时间:2024/04/30 02:05
功能说明:
可以把文章标题中的英文单词的首字母变成大写:)
效果演示:
<%
function PCase(strInput)
'Variable declaration.
Dim strArr
Dim tmpWord
Dim tmpString
Dim last
'Create an array To store Each word In the String separately.
strArr = split(strInput," ")
if ubound(strArr) > 0 Then
For x = lbound(strArr) To ubound(strArr)
'Set Each word To lower Case initially.
strArr(x) = LCase(strArr(x))
'Skip the unimportant words.
Select Case strArr(x)
Case "a"
Case "an"
Case "and"
Case "but"
Case "by"
Case "for"
Case "in"
Case "into"
Case "is"
Case "of"
Case "off"
Case "on"
Case "onto"
Case "or"
Case "the"
Case "to"
Case "a.m."
strArr(x) = "A.M."
Case "p.m."
strArr(x) = "P.M."
Case "b.c."
strArr(x) = "B.C."
Case "a.d."
strArr(x) = "A.D."
Case Else
'Capitalize the first letter, but don't forget To take into account that
'the String may be in Single or Double quotes.
if len(strArr(x)) > 1 Then
if mid(strArr(x),1,1) = "'" or mid(strArr(x),1,1) = """" Then
tmpWord = mid(strArr(x),1,1) & Ucase(mid(strArr(x),2,1)) & mid(strArr(x),3,len(strArr(x))-2)
Else
tmpWord = Ucase(mid(strArr(x),1,1)) & mid(strArr(x),2,len(strArr(x))-1)
End if
strArr(x) = tmpWord
End if
End Select
'The unimportant words may need To be capitalized if they follow a dash, colon,
'semi-colon, Single quote or Double quote.
if x > 0 Then
if instr(strArr(x-1),"-") _
or instr(strArr(x-1),":") _
or instr(strArr(x-1),";") Then
tmpWord = Ucase(mid(strArr(x),1,1)) & mid(strArr(x),2,len(strArr(x))-1)
strArr(x) = tmpWord
End if
End if
Next
Else
strArr(0) = LCase(strArr(0))
End if
'Make sure the first word In the array is upper case, but don't forget To take into account
'that the String may be in Single or Double quotes.
if mid(strArr(0),1,1) = "'" or mid(strArr(0),1,1) = """" Then
tmpWord = mid(strArr(0),1,1) & Ucase(mid(strArr(0),2,1)) & mid(strArr(0),3,len(strArr(0))-2)
Else
tmpWord = Ucase(mid(strArr(0),1,1)) & mid(strArr(0),2,len(strArr(0))-1)
End if
strArr(0) = tmpWord
'Also, make sure the last word In the array is upper case, but don't forget To take into account
'that the String may be in Single or Double quotes.
last = ubound(strArr)
if mid(strArr(last),1,1) = "'" or mid(strArr(last),1,1) = """" Then
tmpWord = mid(strArr(last),1,1) & Ucase(mid(strArr(last),2,1)) & mid(strArr(0),3,len(strArr(last))-2)
Else
tmpWord = Ucase(mid(strArr(last),1,1)) & mid(strArr(last),2,len(strArr(last))-1)
End if
strArr(last) = tmpWord
'Rebuild the whole String from the array parts.
For x = lbound(strArr) To ubound(strArr)
tmpString = tmpString & strArr(x) & " "
Next
PCase = tmpString
End function
%>
- 可以把文章标题中的英文单词的首字母变成大写的函数
- java String类中的方法将一句英文单词的首字母转成大写
- 把输入的字符串中,每个单词的首字母变成大写(单词用空格隔开)
- 将输入字符串中每个单词的首字母变成大写
- php 首字母大写的两个函数
- 把每个单词的首字母转换成大写之疑惑
- 输入一段字符串,把每个单词的首字母改成大写
- 应用:把字符串的首字母大写并统计单词个数
- 把一个字符串的首字母转成大写,其余为小写。(
- 利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字
- 利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字。
- 利用map()函数,把用户输入的英文名字,变为首字母大写,其他小写的规范名字&&键盘输入的整数相加
- EL表达式中的首字母大写造成的bug
- Python将list中的每一项的首字母大写
- 数字变成大写的类,把人民币转化为大写汉字
- 数字变成大写的类,把人民币转化为大写汉字
- 数字变成大写的类,把人民币转化为大写汉字
- 数字变成大写的类,把人民币转化为大写汉字
- 在VBScript中使用类(一)
- 在VBScript中使用类(二)
- 在VBScript中使用类(三)
- 在VBScript中使用类(四)
- ASP中一个用VBScript写的随机数类
- 可以把文章标题中的英文单词的首字母变成大写的函数
- ASP中令人震撼的Debug类(VBScript)
- ASP中一个字符串处理类(VBScript)
- ASP中一个字符串处理类(加强)(VBScript)
- ***用VS2003调试ASP的方法和体会***
- 推荐openssl专业论坛http://gdwzh.126.com
- openssl之BIO系列之1---抽象的IO接口
- opensslBIO系列之2---BIO结构和BIO相关文件介绍
- BIO系列之3---BIO的声明和释放等基本操作