REGEXP_SUBSTR Function - Oracle to MySQL Migration

In Oracle and MySQL, the REGEXP_SUBSTR function returns the substring that matches the regular expression.

Oracle:

  -- Match a string until a comma and return the 2nd occurrence
  SELECT REGEXP_SUBSTR('aa,bbb,cccc', '[^,]+', 1, 2) FROM dual;
  /* bbb */
 
  -- Match a string until a blank and return the 3rd occurrence
  SELECT REGEXP_SUBSTR('aa bbb cccc', '[^[:blank:]]+', 1, 3) FROM dual;
  /* cccc */
 
  -- Start at position 4 and return the 1st occurrence
  SELECT REGEXP_SUBSTR('aa bbb cccc', '[^[:blank:]]+', 4, 1) FROM dual;
  /* bbb */

MySQL:

  -- Match a string until a comma and return the 2nd occurrence
  SELECT REGEXP_SUBSTR('aa,bbb,cccc', '[^,]+', 1, 2);
  /* bbb */
 
  -- Match a string until a blank and return the 3rd occurrence
  SELECT REGEXP_SUBSTR('aa bbb cccc', '[^[:blank:]]+', 1, 3);
  /* cccc */
 
  -- Start at position 4 and return the 1st occurrence
  SELECT REGEXP_SUBSTR('aa bbb cccc', '[^[:blank:]]+', 4, 1);
  /* bbb */

For more information, see Oracle to MySQL Migration.