求一个用正则把全角英文和数字替换成半角的 php的这样写:$value = preg_replace('/\xa3([\xa1-\xfe])/e', 'chr(ord(\1)-0x80)', $value); js的有没有人告诉一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function SBC(text) { return text && text.replace(/[\x20-\x7e]/g, function($0) { return $0 == " " ? "\u3000" : String.fromCharCode($0.charCodeAt(0) + 0xfee0); });}function CBS(text) { return text && text.replace(/[\u3000\uff01-\uff5f]/g, function($0) { return $0 == "\u3000" ? " " : String.fromCharCode($0.charCodeAt(0) - 0xfee0); });}alert(SBC("zswang 2010"));alert(CBS("zswang 2010")); 不太完美吧!正则的全角范围应该是[\u3000\uff01-\uffE6] http://unicodelookup.com/#fullwidth/1 IE浏览器 link标签 onload事件在火狐(ff)下没效 原始文件已经修改,但是刷新链接没有效果 新手事件代码是不是这样一来的形式? 右侧QQ在线联系滑动无法正常运行,跟DOCTYPE有关 高手进来解答,困扰我许久的问题 <Select></select>互动问题 网页A重定向到网页B,如何在网页B中知道网页A的地址? 怎样改变表单内容?在线等!! jquery animate回调函数 window.onscroll实现悬浮窗口 JS/jQuery 怎么才能实现“要刷新的地方出现‘载入中...’字样”?
return text && text.replace(/[\x20-\x7e]/g, function($0) {
return $0 == " " ? "\u3000" : String.fromCharCode($0.charCodeAt(0) + 0xfee0);
});
}function CBS(text) {
return text && text.replace(/[\u3000\uff01-\uff5f]/g, function($0) {
return $0 == "\u3000" ? " " : String.fromCharCode($0.charCodeAt(0) - 0xfee0);
});
}alert(SBC("zswang 2010"));
alert(CBS("zswang 2010"));
不太完美吧!正则的全角范围应该是[\u3000\uff01-\uffE6]
http://unicodelookup.com/#fullwidth/1