2010-01-27 by text , 0 views
Gblog输入tag标签时都是用逗号——“,”隔开的,由于中文逗号和英文逗号是不同的,这样输入时就会遇到问题,必须统一成中文逗号或者英文逗号,这样分辨时才不会出错。
我们最好在存入数据库之前把它们统一一下,免得以后遇到麻烦,
主要方法是使用ASP的替换函数
VBScript Replace 函数 定义和用法Replace 函数可使用一个字符串替换另一个字符串指定的次数。
语法
Replace(string,find,replacewith[,start[,count[,compare]]])
| 参数 | 描述 |
|---|---|
| string | 必需的。需要被搜索的字符串。 |
| find | 必需的。将被替换的字符串部分。 |
| replacewith | 必需的。用于替换的子字符串。 |
| start | 可选的。规定开始位置。默认是 1。 |
| count | 可选的。规定指定替换的次数。默认是 -1,表示进行所有可能的替换。 |
| compare | 可选的。规定所使用的字符串比较类型。默认是 0。 |
| 常数 | 值 | 描述 |
|---|---|---|
| vbBinaryCompare | 0 | 执行二进制比较。 |
| vbTextCompare | 1 | 执行文本比较。 |
Replace 可能返回的值:
| 参数可能的取值 | Replace 返回的值 |
|---|---|
| expression 为零长度 | 零长度字符串 ("")。 |
| expression 为 Null | 错误。 |
| find 参数为零长度 | expression 的副本。 |
| replacewith 参数为零长度 | expression 的副本,其中删除了所有由 find 参数指定的内容。 |
| start > Len(expression) | 零长度字符串。 |
| count 为 0 | expression 的副本。 |
实例
例子 1
dim txt txt="This is a beautiful day!" document.write(Replace(txt,"beautiful","horrible"))
输出:
This is a horrible day!
具体到http://www.goodtext.org/的Gblog系统中,就是在入库前用替换函数统一符号,我们都把它们变成中文逗号就可以了,
dim tags
tags=request("tags")
tags=Replace(tags,",",",")
这样就可以了,不会出现符号不统一的问题了
tagged: tag,GBlog,Blog,博客