Monday, June 25, 2012

MySQL - Regular Expressions & REPLACE | preg_replace


Method 1:
MySQL Regular Expression UDFs


Method 2: Replace. I like it! Haha!
From 
a~b}c{d`e_f^g\\h[i?j=k;l.m-n,o*p(q&r$s"t u|v]x@y>z<0:1+2)3\'4%5#6!7\r8\f9\v0\naz\t09\b
To 
abcdeghijklmnopqrstuxyz01234567890az09


select replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace(
'a~b}c{d`e_f^g\\h[i?j=k;l.m-n,o*p(q&r$s"t u|v]x@y>z<0:1+2)3\'4%5#6!7\r8\f9\v0\naz\t09\b',
'~', ''),
'}', ''),
'{', ''),
'`', ''),
'_', ''),
'^', ''),
'\\', ''),
'[', ''),
'?', ''),
'=', ''),
';', ''),
'.', ''),
'-', ''),
',', ''),
'*', ''),
'(', ''),
'&', ''),
'$', ''),
'"', ''),
' ', ''),
'|', ''),
']', ''),
'@', ''),
'>', ''),
'<', ''),
':', ''),
'+', ''),
')', ''),
'\'', ''),
'%', ''),
'#', ''),
'!', ''),
'\r', ''),
'\f', ''),
'\v', ''),
'\n', ''),
'\t', ''),
'\b', '')

No comments:

Post a Comment