Created
July 31, 2014 14:45
-
-
Save padak/c0c867452942e4728d48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP FUNCTION IF EXISTS alphanum; | |
DELIMITER | | |
CREATE FUNCTION alphanum( str CHAR(32) ) RETURNS CHAR(16) | |
BEGIN | |
DECLARE i, len SMALLINT DEFAULT 1; | |
DECLARE ret CHAR(32) DEFAULT ''; | |
DECLARE c CHAR(1); | |
SET len = CHAR_LENGTH( str ); | |
REPEAT | |
BEGIN | |
SET c = MID( str, i, 1 ); | |
IF c REGEXP '[[:alnum:]]' THEN | |
SET ret=CONCAT(ret,c); | |
END IF; | |
SET i = i + 1; | |
END; | |
UNTIL i > len END REPEAT; | |
RETURN ret; | |
END | | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment