RT
public string[] GetString(string htmlStr)
{
Regex regObj = new Regex("^[?\uFF10-\uFF19\uFF41-\uFF5A\uFF21-\uFF3A]*$",RegexOptions.Compiled|RegexOptions.IgnoreCase);
string [] strAry = new string [regObj.Matches(htmlStr).Count] ;
int i = 0;
foreach (Match matchItem in regObj.Matches(htmlStr))
{
strAry[i] = matchItem.Value;
i++;
}
return strAry ;
}
这是我原有的代码
这一句
new Regex("^[?\uFF10-\uFF19\uFF41-\uFF5A\uFF21-\uFF3A]*$",RegexOptions.Compiled|RegexOptions.IgnoreCase);
怎么写才能匹配出全角字符
public string[] GetString(string htmlStr)
{
Regex regObj = new Regex("^[?\uFF10-\uFF19\uFF41-\uFF5A\uFF21-\uFF3A]*$",RegexOptions.Compiled|RegexOptions.IgnoreCase);
string [] strAry = new string [regObj.Matches(htmlStr).Count] ;
int i = 0;
foreach (Match matchItem in regObj.Matches(htmlStr))
{
strAry[i] = matchItem.Value;
i++;
}
return strAry ;
}
这是我原有的代码
这一句
new Regex("^[?\uFF10-\uFF19\uFF41-\uFF5A\uFF21-\uFF3A]*$",RegexOptions.Compiled|RegexOptions.IgnoreCase);
怎么写才能匹配出全角字符
public static string CharConverter(string source)
{
System.Text.StringBuilder result = new System.Text.StringBuilder(source.Length, source.Length);
for (int i=0; i<source.Length; i++)
{
if (source[i] >= 65281 && source[i] <= 65373)
{
result.Append((char)(source[i] - 65248));
}
else if (source[i] == 12288)
{
result.Append(' ');
}
else
{
result.Append(source[i]);
}
}
return result.ToString();
}
c =event.srcElement.value;
myArray= new Array();
for(i=0;i<c.length;i++)
{
if(c.charCodeAt!=null&&String.fromCharCode!=null)
{
var charCode=c.charCodeAt(i);
if(charCode>0xfee0){
myArray[i]=String.fromCharCode(charCode-0xfee0);
}
else
myArray[i]=String.fromCharCode(charCode);
}
}
event.srcElement.value=str;
}