search

Home  >  Q&A  >  body text

Grouping in REGEXP_SUBSTR() in MySQL 8.x

I'm trying to use a regular expression that I know about, but it doesn't seem to work in MYSQL v8.0. I'm trying to extract the filename (something.txt) from some_str variable. It keeps returning NULL. Not sure what I'm doing wrong in the pattern.

set @some_str = "{'A': 1234, 'fname': 'something.txt'}";
select regexp_substr(@some_str, "\{'\w+':\s+\d+,\s+'\w+':\s+'(.+)'\}") ;
-- should return:  something.txt

P粉514458863P粉514458863236 days ago524

reply all(1)I'll reply

  • P粉670838735

    P粉6708387352024-04-03 09:00:46

    db<>violinhere

    reply
    0
  • Cancelreply