0

I know that MySQL does not have a regular expression replace function but I wondered if anyone has written a user defined function that I could use? I know it's not good to just ask for code answers but I am not very skilled in MySQL and was just looking for some help. If there isn't I can accept that.

Thanks

Bobbake4
  • 24,509
  • 9
  • 59
  • 94
  • What are you trying to do with the replace functionality? – Jared Farrish Oct 10 '11 at 01:17
  • possible duplicate of [How to do a regular expression replace in MySQL?](http://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql) – tadman Oct 10 '11 at 01:19

2 Answers2

1

Try this site:

http://www.mysqludf.org/lib_mysqludf_preg/

imm
  • 5,837
  • 1
  • 26
  • 32
  • This sounds great. It requires installing a library to use perl regex but is a valid solution. – Bobbake4 Oct 10 '11 at 01:29
  • Alternatively, see https://launchpad.net/mysql-udf-regexp , which was recommended in the post noted by @tadman. – imm Oct 10 '11 at 01:30
0
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<:+)\'%#!\r\f\v\naz\t09\b',

  '~', ''), '}', ''), '{', ''), '`', ''), '_', ''),
  '^', ''), '\\', ''), '[', ''), '?', ''), '=', ''),
  ';', ''), '.', ''), '-', ''), ',', ''), '*', ''),
  '(', ''), '&', ''), '$', ''), '"', ''), ' ', ''),
  '|', ''), ']', ''), '@', ''), '>', ''), '<', ''),
  ':', ''), '+', ''), ')', ''), '\'', ''), '%', ''),
  '#', ''), '!', ''), '\r', ''), '\f', ''), '\v', ''),
  '\n', ''), '\t', ''), '\b', '')

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<:+)\'%#!\r\f\v\naz\t09\b

To

abcdeghijklmnopqrstuxyzaz09

MySQL - Regular Expressions & REPLACE

HanhNghien
  • 225
  • 1
  • 6