param { * } str param { * } space export const filterHTMLTag = ( str , space = false ) => { str = str . replace ( /<\/?[^>]*>/g , '' ) ; if ( space ) { str = str . replace ( /[|]*\n/ , '' ) ; } str = str . replace ( /&npsp;/gi , '' ) ; return str ; } ; param { * } str param { * } type export const checkStr = ( str , type ) => { if ( typeof str !== 'string' ) { return false ; } switch ( type ) { case 'phone' : return /^1[3|4|5|7|8][0-9]{9}$/ . test ( str ) ; case 'tel' : return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/ . test ( str ) ; case 'card' : return /^\d{15}|\d{18}$/ . test ( str ) ; case 'pwd' : return /^[a-zA-Z]\w{5,17}$/ . test ( str ) ; case 'postal' : return /[1-9]\d{5}(?!\d)/ . test ( str ) ; case 'QQ' : return /^[1-9][0-9]{4,9}$/ . test ( str ) ; case 'email' : return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/ . test ( str ) ; case 'money' : return /^\d*(?:\.\d{0,2})?$/ . test ( str ) ; case 'URL' : return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/ . test ( str ) ; case 'IP' : return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/ . test ( str ) ; case 'date' : return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/ . test ( str ) || /^(\d{4})\-(\d{2})\-(\d{2})$/ . test ( str ) ; case 'number' : return /^[0-9]$/ . test ( str ) ; case 'english' : return /^[a-zA-Z]+$/ . test ( str ) ; case 'chinese' : return /^[\u4E00-\u9FA5]+$/ . test ( str ) ; case 'lower' : return /^[a-z]+$/ . test ( str ) ; case 'upper' : return /^[A-Z]+$/ . test ( str ) ; case 'HTML' : return /<("[^"]*"|'[^']*'|[^'">])*>/ . test ( str ) ; default : return false ; } } ;