javascript去除字符串中所有标点符号和提取纯文本

来源:互联网 发布:mac下思维导图 编辑:程序博客网 时间:2024/05/19 17:11

转自:http://www.ways2u.com/?post=82

用正则表达式除字符串中所有标点符号

var str="jfkldsjalk,.23@#!$$k~!  @#$%^&*()(_+-=|\{}[]';:,./<>??gg  g~```gf";   str=str.replace(/[\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?]/g,"");      alert(str); 


用正则表达式提取html中文本

str='<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><br/ >';    str=str.replace(/<[^>]*>|/g,"");     alert(str); 


0 0