欢迎光临
我们一直在努力

可以把文章标题中的英文单词的首字母变成大写的函数-ASP教程,ASP应用

建站超值云服务器,限时71元/月

功能说明:

可以把文章标题中的英文单词的首字母变成大写:)

效果演示:

<%

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 dont 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 dont 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 dont 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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 可以把文章标题中的英文单词的首字母变成大写的函数-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章