一般字符串函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一般字符串函数相关的知识,希望对你有一定的参考价值。
A small collection of the most wanted string-functions in ASP / VB.
' Count the chars in a string ' ========= response.write(len("1234567")) ' Output: 7 ' ========= ' Edit date ' ========= DateAdd(Interval, Amount, yourDate) DateAdd("ww", 2, now) DateAdd("ww", -2, now) ' Value Description ' ============================ ' yyyy Year ' q Quarter ' m Month ' y Day of the year ' d Day ' w Weekday ' ww Week of a year ' h Hour ' n Minute ' s Second ' ========= ' Search in string ' ========= foo = "12.34" response.write(instr(foo, ".")) ' Output: 3 ' ========= ' Cut string ' ========= response.write(left("1234567", 3)) ' Output: 123 response.write(right("1234567", 3)) ' Output: 567 response.write(mid("1234567", 3, 2)) ' Output: 34 response.write(mid("1234567", 3)) ' Output: 567 ' ========= ' String into float ' ========= String = "12,26" Float = CDbl(String) Result = Float + 7.74 ' ========= ' String into int ' ========= String = "12,26" Int = CInt(String) Result = Int + 7.74 ' ========= ' Split string ' ========= foo = "My-Name" bar = split(foo, "-") response.write(bar(0) & " " & bar(1)) ' Output: My Name ' ========= ' Replace' ========= foo = "My-Name" response.write(replace(foo,"-"," ")) ' Output: My Name ' =========
以上是关于一般字符串函数的主要内容,如果未能解决你的问题,请参考以下文章