验证ASP中的字符串 [英] validating the string in ASP
问题描述
嗨!我是这个论坛的新手,在ASP中需要一些帮助
如何验证字符串,以便它只有字符
的ASCII 32到91和93到122?此外,如果字符串包含
逗号(,),则整个字符串应在引号内转换("")
ie
如果字符串是:example string,Ok
它应该是:" example string,Ok"
-
asimrafi
------------------------------------- -----------------------------------
发表于 http://www.codecomments.com
-------- -------------------------------------------------- --------------
Hi! i m new to this forum and need some help in ASP
how can i validate a string so that it have only the characters
of ASCII 32 to 91 and 93 to 122 ? Also if the string contains the
comma (,) the whole string should be converted inside the quotes ("")
i.e.
if the string is: example string, Ok
it should be: "example string, Ok"
--
asimrafi
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
推荐答案
asimrafi写道:
asimrafi wrote:
嗨!我是这个论坛的新手,在ASP中需要一些帮助
如何验证字符串,使其只有ASCII 32到91和93到122的字符?此外,如果字符串包含
逗号(,),则整个字符串应在引号内引用("")
如果字符串为:example string,好的
它应该是:示例字符串,确定
-
asimrafi
--------------- -------------------------------------------------- -------
通过 http://www.codecomments.com
-------------------------------------------- ----------------------------
Hi! i m new to this forum and need some help in ASP
how can i validate a string so that it have only the characters
of ASCII 32 to 91 and 93 to 122 ? Also if the string contains the
comma (,) the whole string should be converted inside the quotes ("")
i.e.
if the string is: example string, Ok
it should be: "example string, Ok"
--
asimrafi
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
在服务器端,使用VBScript正则表达式:
http://msdn.microsoft.com/library/de...ting051099.asp
在客户端,使用Javascript版本:
http:// www .regular-expressions.info / javascript.html
-
Mike Brind
On the server side, use VBScript Regular Expressions:
http://msdn.microsoft.com/library/de...ting051099.asp
On the client side, use the Javascript version:
http://www.regular-expressions.info/javascript.html
--
Mike Brind
asimrafi于2006年6月在microsoft.public.inetserver.asp.general写道:
asimrafi wrote on 06 mrt 2006 in microsoft.public.inetserver.asp.general:
嗨!我是这个论坛的新手,在ASP中需要一些帮助
如何验证字符串,使其只有ASCII 32到91和93到122的字符?此外,如果字符串包含
逗号(,),则整个字符串应在引号内引用("")
如果字符串为:example string,好吧
它应该是:示例字符串,确定
Hi! i m new to this forum and need some help in ASP
how can i validate a string so that it have only the characters
of ASCII 32 to 91 and 93 to 122 ? Also if the string contains the
comma (,) the whole string should be converted inside the quotes ("")
i.e.
if the string is: example string, Ok
it should be: "example string, Ok"
<%''vbscript
dim a
a =" example"& vbcr&" stringX Ok"
response.write convertMe(a)& "< br>"
a =" example"& vbcr&" string,Ok"
response.write convertMe(a )& "< br>"
%>
< script language =''jscript''runat =''服务器''>
// 32-91 space- [和93-122] -z
函数convertMe(s){
s = s.replace(/ [^ -\ [\] -z] /,'''');
if(/,/。test(s))s =''" ''+ s +''"'';
返回s;
}
< / script>
-
Evertjan。
荷兰。
(请将x''es更改为我的电子邮件地址中的点数)
<% ''vbscript
dim a
a = "example "&vbcr&"stringX Ok"
response.write convertMe(a) & "<br>"
a = "example "&vbcr&"string, Ok"
response.write convertMe(a) & "<br>"
%>
<script language=''jscript'' runat=''server''>
// 32-91 space-[ and 93-122 ]-z
function convertMe(s){
s = s.replace(/[^ -\[\]-z]/,'''');
if (/,/.test(s)) s = ''"''+s+''"'';
return s;
}
</script>
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)
Mike Brind于06年6月在
microsoft.public.inetserver.asp.general写道:
Mike Brind wrote on 06 mrt 2006 in
microsoft.public.inetserver.asp.general:
在服务器端,使用VBScript正则表达式:
http://msdn.microsoft.com/library/de...y/en-us/dnclin
ic / html / scripting051099.asp
为什么这个erversie专注于vbscript?
Jscript正则表达式是更清晰的代码。
在客户端,使用Javascript版本:
http://www.regular-expressions.info/javascript.html
On the server side, use VBScript Regular Expressions:
http://msdn.microsoft.com/library/de...y/en-us/dnclin
ic/html/scripting051099.asp
Why this serversie preoccupation with vbscript?
Jscript regex is cleaner code.
On the client side, use the Javascript version:
http://www.regular-expressions.info/javascript.html
-
Evertjan。
荷兰。
(请更改x''我的电子邮件中的点数)
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)
这篇关于验证ASP中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!