I am going to use something similar for each line (I will replace every bad char with "O"):
CREATE FUNCTION removeNonAlphaNum (p_zthes VARCHAR(255)) RETURNS VARCHAR(255)
BEGIN
DECLARE v_i INTEGER;
DECLARE v_char VARCHAR(1);
DECLARE v_res VARCHAR(255);
SET v_i := LENGTH(p_zthes);
SET v_res:=p_zthes;
WHILE v_i > 0 DO
SET v_char := SUBSTRING(p_zthes, v_i, 1);
IF (SELECT v_char REGEXP '[^a-zA-Z0-9]') THEN
SET v_res := REPLACE(v_res, v_char, 'O');
END IF;
SET v_i := v_i - 1;
END WHILE;
return v_res;
END
but I thought I could avoid such a monster (iterating through lines in lines and checking each of the regular expressions ... bleeeeee ...): - / I still need to test it.
Are there any more sexual solutions?
source
share