var re1 = /(\d{1,3})+(?:\.\d+)?/g var re2 = /[\u4e00-\u9fa5]{2,}/g var str="11我22们33两个"; var arr1 = str.match(re1); var arr2 = str.match(re2); arr1=11,22,33 arr2=我,们,两个
替换字符串中的数字 var text = "abc123"; text=text.replace(/[0-9]/ig,""); 此时得到的text为"abc". 替换字符串中的非数字 var text = "abc123"; text=text.replace(/[^0-9]/ig,""); 此时得到的text为"123". i表示区分大小写. g表示进行全局匹配.
var res = "a-b-c-d";var index = find(res,'-',1); //字符串res中第二个‘-’的下标 var ress = res.substring(index); //ress的值为 "-c-d" function find(str,cha,num){ var x=str.indexOf(cha); for(var i=0;i<num;i++){ x=str.indexOf(cha,x+1); } return x;}
方法一: var jmz = {}; jmz.GetLength = function(str) { ///<summary>获得字符串实际长度,中文2,英文1</summary> ///<param name="str">要获得长度的字符串</param> var realLength = 0, len = str.length, charCode = -1; for (var i = 0; i < len; i++) { cha
方法一: var jmz = {}; jmz.GetLength = function(str) { ///<summary>获得字符串实际长度,中文2,英文1</summary> ///<param name="str">要获得长度的字符串</param> var realLength = 0, len = str.length, charCode = -1; for (var i = 0; i < len; i++) { cha
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ
)) ) BEGIN ; ) default ''; set v_length=CHAR_LENGTH(Varstring); DO )) )) ) THEN )); END IF; ; END WHILE; RETURN REVERSE(v_Tmp); END; 调用函数: select GetNum(字段) from table;-- GetNum中的字段名不需要用引号括起来
s = "dede323frf54de23" l = len(s) numbers = [] i = 0 while i < l: num = '' symbol = s[i] while '0' <= symbol <= '9': # symbol.isdigit() num += symbol i += 1 if i < l: symbol = s[i] else: break i += 1 if num != '': numbers.append(int(