js提取分别提取数字、中文、英文的方法

来源:半月设计 发布人:GuoBar 发布时间:2005-7-22 15:30:25 人气: 所属栏目:网站制作-WEB

<input type="text" id="oText" value="半月设计124:http://www.guobar.com/1245">
<input type="button" value="提取数字" onclick="window.alert(self['oText'].value=self['oText'].value.replace(/[^\d]/g,''));">
<input type="button" value="提取中文" onclick="window.alert(self['oText'].value=self['oText'].value.replace(/[^\u4E00-\u9FA5]/g,''));">
<input type="button" value="提取英文" onclick="window.alert(self['oText'].value=self['oText'].value.replace(/[^a-zA-Z]/g,''));">

可将代码复制新建一个htm文件.运行即可看到效果




生成时间:2006-5-26 0:25:25