提取字符串中的数字
Posted beibidewomen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了提取字符串中的数字相关的知识,希望对你有一定的参考价值。
CREATE DEFINER=`root`@`localhost` FUNCTION `getNum`(Varstring varchar(50)) RETURNS varchar(30) CHARSET utf8 BEGIN DECLARE v_length INT DEFAULT 0; DECLARE v_Tmp varchar(50) default ‘‘; DECLARE s_len INT DEFAULT 0; DECLARE e_len INT DEFAULT 0; set v_length=CHAR_LENGTH(Varstring); set s_len = v_length - 5; set Varstring = right(Varstring,s_len); set v_length=CHAR_LENGTH(Varstring); set e_len = v_length - 18; set Varstring = left(Varstring,e_len); WHILE v_length > 0 DO IF (ASCII(mid(Varstring,v_length,1))>47 and ASCII(mid(Varstring,v_length,1))<58 or ASCII(mid(Varstring,v_length,1))=46 or mid(Varstring,v_length,1)=‘万‘) THEN set v_Tmp=concat(v_Tmp,mid(Varstring,v_length,1)); END IF; SET v_length = v_length - 1; END WHILE; RETURN REVERSE(v_Tmp); END
以上是关于提取字符串中的数字的主要内容,如果未能解决你的问题,请参考以下文章