add: "mysql_sanitize_string.sql"
This commit is contained in:
commit
16a66c80a5
1 changed files with 19 additions and 0 deletions
19
mysql_sanitize_string.sql
Normal file
19
mysql_sanitize_string.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
DELIMITER $$
|
||||
|
||||
CREATE FUNCTION remove_bracketed_text(input_text TEXT)
|
||||
RETURNS TEXT DETERMINISTIC
|
||||
BEGIN
|
||||
DECLARE output_text TEXT DEFAULT input_text;
|
||||
DECLARE previous_text TEXT;
|
||||
|
||||
-- Loop until no more bracketed text is found
|
||||
REPEAT
|
||||
SET previous_text = output_text;
|
||||
SET output_text = REGEXP_REPLACE(output_text COLLATE utf8mb4_unicode_ci, '\\[[^]]*\\]', '');
|
||||
UNTIL output_text = previous_text
|
||||
END REPEAT;
|
||||
|
||||
RETURN output_text;
|
||||
END $$
|
||||
|
||||
DELIMITER ;
|
||||
Loading…
Add table
Reference in a new issue