function DealJsText(Str)
if not isnull(Str) then
Dim re,po,ii 'Str = replace(Str, """", "\""")
Str = Replace(Str, CHR(9), " ")
Str = Replace(Str, CHR(39), "'")
Str = Replace(Str, CHR(13), "")
Str = Replace(Str, CHR(10) & CHR(13), "</P><P> ")
Str = Replace(Str, CHR(10), "")
Str = Replace(Str, "‘", "'")
Str = Replace(Str, "’", "'")
'网友冷情圣郎提供
Str = Replace(Str, "\", "\\")
Str = Replace(Str, CHR(32), " ")
Str = Replace(Str, CHR(34), "\""")
Str = Replace(Str, CHR(39), "'") Set re=new RegExp
re.IgnoreCase =true
re.Global=True
po=0
ii=0 re.Pattern="(javascript)"
Str=re.Replace(Str,"<I>javascript</I>")
re.Pattern="(jscript:)"
Str=re.Replace(Str,"<I>jscript:</I>")
re.Pattern="(js:)"
Str=re.Replace(Str,"<I>js:</I>")
re.Pattern="(</SCRIPT>)"
Str=re.Replace(Str,"</script>")
re.Pattern="(<SCRIPT)"
Str=re.Replace(Str,"<script") DealJsText = Str
End if
end Function
if not isnull(Str) then
Dim re,po,ii 'Str = replace(Str, """", "\""")
Str = Replace(Str, CHR(9), " ")
Str = Replace(Str, CHR(39), "'")
Str = Replace(Str, CHR(13), "")
Str = Replace(Str, CHR(10) & CHR(13), "</P><P> ")
Str = Replace(Str, CHR(10), "")
Str = Replace(Str, "‘", "'")
Str = Replace(Str, "’", "'")
'网友冷情圣郎提供
Str = Replace(Str, "\", "\\")
Str = Replace(Str, CHR(32), " ")
Str = Replace(Str, CHR(34), "\""")
Str = Replace(Str, CHR(39), "'") Set re=new RegExp
re.IgnoreCase =true
re.Global=True
po=0
ii=0 re.Pattern="(javascript)"
Str=re.Replace(Str,"<I>javascript</I>")
re.Pattern="(jscript:)"
Str=re.Replace(Str,"<I>jscript:</I>")
re.Pattern="(js:)"
Str=re.Replace(Str,"<I>js:</I>")
re.Pattern="(</SCRIPT>)"
Str=re.Replace(Str,"</script>")
re.Pattern="(<SCRIPT)"
Str=re.Replace(Str,"<script") DealJsText = Str
End if
end Function
解决方案 »
- 统计每天的用户登陆数,统计新增用户数(当天注册),所有登录用户的登录情况
- 【急】页面缓存,但有个登录的用户控件不加缓存能实现吗?
- 第三方控件
- 为什么套用母板页和updatepanle后遍历不到页面上的控件
- 为什么加了这段javascript代码,flash就无法显示?
- Ajax导致Request.Form不可用
- 请问.net 可否带.net 1.1 和.net 2.0 ?????????????
- Repeater的问题
- 求VB版的电子商城程序源代码,本人对购物这块不太熟悉,有知道的,请告知我一下
- 本人初学!请多多指教。asp.net中列子出现了问题!(在线等)
- 怎么把客户端上的数据导到网上去,求救高手的解决方案
- ASP.NET + Access开发的网站
{
public StringUtil()
{
//
// TODO: 在此处添加构造函数逻辑
//
} /// <summary>
/// 从字符串中的尾部删除指定的字符串
/// </summary>
/// <param name="sourceString"></param>
/// <param name="removedString"></param>
/// <returns></returns>
public static string Remove(string sourceString,string removedString)
{
try
{
if(sourceString.IndexOf(removedString)<0)
throw new Exception("原字符串中不包含移除字符串!");
string result = sourceString;
int lengthOfSourceString = sourceString.Length;
int lengthOfRemovedString = removedString.Length;
int startIndex = lengthOfSourceString - lengthOfRemovedString;
string tempSubString = sourceString.Substring(startIndex);
if(tempSubString.ToUpper() == removedString.ToUpper())
{
result = sourceString.Remove(startIndex,lengthOfRemovedString);
}
return result;
}
catch
{
return sourceString;
}
} /// <summary>
/// 获取拆分符右边的字符串
/// </summary>
/// <param name="sourceString"></param>
/// <param name="splitChar"></param>
/// <returns></returns>
public static string RightSplit(string sourceString, char splitChar)
{
string result=null;
string[] tempString = sourceString.Split(splitChar);
if(tempString.Length >0)
{
result = tempString[tempString.Length-1].ToString();
}
return result;
}
/// <summary>
/// 获取拆分符左边的字符串
/// </summary>
/// <param name="sourceString"></param>
/// <param name="splitChar"></param>
/// <returns></returns>
public static string LeftSplit(string sourceString, char splitChar)
{
string result=null;
string[] tempString = sourceString.Split(splitChar);
if(tempString.Length >0)
{
result = tempString[0].ToString();
}
return result;
} /// <summary>
/// 去掉最后一个逗号
/// </summary>
/// <param name="origin"></param>
/// <returns></returns>
public static string DelLastComma(string origin)
{
if(origin.IndexOf(",") == -1)
{
return origin;
}
return origin.Substring(0,origin.LastIndexOf(","));
} /// <summary>
/// 删除不可见字符
/// </summary>
/// <param name="sourceString"></param>
/// <returns></returns>
public static string DeleteUnVisibleChar(string sourceString)
{
System.Text.StringBuilder sBuilder = new System.Text.StringBuilder(131);
for(int i = 0;i < sourceString.Length; i++)
{
int Unicode = sourceString[i];
if(Unicode >= 16)
{
sBuilder.Append(sourceString[i].ToString());
}
}
return sBuilder.ToString();
} /// <summary>
/// 获取数组元素的合并字符串
/// </summary>
/// <param name="stringArray"></param>
/// <returns></returns>
public static string GetArrayString(string[] stringArray)
{
string totalString = null;
for(int i=0;i<stringArray.Length;i++)
{
totalString = totalString + stringArray[i];
}
return totalString;
} /// <summary>
/// 获取某一字符串在字符串数组中出现的次数
/// </summary>
/// <param name="stringArray" type="string[]">
/// <para>
///
/// </para>
/// </param>
/// <param name="findString" type="string">
/// <para>
///
/// </para>
/// </param>
/// <returns>
/// A int value...
/// </returns>
public static int GetStringCount(string[] stringArray,string findString)
{
int count = -1;
string totalString = GetArrayString(stringArray);
string subString = totalString; while(subString.IndexOf(findString)>=0)
{
subString = totalString.Substring(subString.IndexOf(findString));
count += 1;
}
return count;
} /// <summary>
/// 获取某一字符串在字符串中出现的次数
/// </summary>
/// <param name="stringArray" type="string">
/// <para>
/// 原字符串
/// </para>
/// </param>
/// <param name="findString" type="string">
/// <para>
/// 匹配字符串
/// </para>
/// </param>
/// <returns>
/// 匹配字符串数量
/// </returns>
public static int GetStringCount(string sourceString,string findString)
{
int count = 0;
int findStringLength = findString.Length;
string subString = sourceString; while(subString.IndexOf(findString)>=0)
{
subString = subString.Substring(subString.IndexOf(findString)+findStringLength);
count += 1;
}
return count;
} /// <summary>
/// 截取从startString开始到原字符串结尾的所有字符
/// </summary>
/// <param name="sourceString" type="string">
/// <para>
///
/// </para>
/// </param>
/// <param name="startString" type="string">
/// <para>
///
/// </para>
/// </param>
/// <returns>
/// A string value...
/// </returns>
public static string GetSubString(string sourceString,string startString)
{
try
{
int index = sourceString.ToUpper().IndexOf(startString);
if(index>0)
{
return sourceString.Substring(index);
}
return sourceString;
}
catch
{
return "";
}
} public static string GetSubString(string sourceString,string beginRemovedString,string endRemovedString)
{
try
{
if(sourceString.IndexOf(beginRemovedString)!=0)
beginRemovedString = ""; if(sourceString.LastIndexOf(endRemovedString,sourceString.Length - endRemovedString.Length)<0)
endRemovedString = ""; int startIndex = beginRemovedString.Length;
int length = sourceString.Length - beginRemovedString.Length - endRemovedString.Length ;
if(length>0)
{
return sourceString.Substring(startIndex,length);
}
return sourceString;
}
catch
{
return sourceString;;
}
}
/// <summary>
/// 按字节数取出字符串的长度
/// </summary>
/// <param name="strTmp">要计算的字符串</param>
/// <returns>字符串的字节数</returns>
public static int GetByteCount(string strTmp)
{
int intCharCount=0;
for(int i=0;i<strTmp.Length;i++)
{
if(System.Text.UTF8Encoding.UTF8.GetByteCount(strTmp.Substring(i,1))==3)
{
intCharCount=intCharCount+2;
}
else
{
intCharCount=intCharCount+1;
}
}
return intCharCount;
} /// <summary>
/// 按字节数要在字符串的位置
/// </summary>
/// <param name="intIns">字符串的位置</param>
/// <param name="strTmp">要计算的字符串</param>
/// <returns>字节的位置</returns>
public static int GetByteIndex(int intIns,string strTmp)
{
int intReIns=0;
if(strTmp.Trim()=="")
{
return intIns;
}
for(int i=0;i<strTmp.Length;i++)
{
if(System.Text.UTF8Encoding.UTF8.GetByteCount(strTmp.Substring(i,1))==3)
{
intReIns=intReIns+2;
}
else
{
intReIns=intReIns+1;
}
if(intReIns>=intIns)
{
intReIns=i+1;
break;
}
}
return intReIns;
}
}