regex - Regex_replace not replacing correctly in Oracle SQL -
i'm trying following regex expression work oracle sql:
select regexp_replace(' "abc_78": 123, ', '.*?abc.*?: (.*?),.*', '\1') dual; select regexp_replace(' "abc_78": 123, "def_79": [', '.*?abc.*?: (.*?),', '\1') dual;
the first 1 returning "123"
(which deem correct) while second 1 returning "123 "def_79": ["
.
what's issue @ stake here? bad regex or weird functioning of oracle? regex seems work when tried against sublime text. i'm running query directly off oracle sql developer.
thanks
it's replacing correctly.
select regexp_replace(' "abc_78": 123, "def_79": [', '.*?abc.*?: (.*?),', '\1') dual;
first: (regex engine) finds '"abc_78": 123' 123 group $1. replaces 'abc_78: 123' group 1 123.
and have little diffrence in regex patterns like:
'.*?abc.*?: (.*?),.*', '\1') dual; '.*?abc.*?: (.*?),', '\1') dual;
missing .* in 2nd pattern.
if want retrieve 123 strings, better use regex_substr
select regexp_substr(' "abc_78": 123, ','\d+',1,2) dual;
Comments
Post a Comment