SELECT data, regexp_replace(data, '.*"xyz":"(.*)","abc".*', '\1') AS new_data_field
FROM (
SELECT data FROM "production-data-analysis".dw_data WHERE data_type_id=9
) nested_0
This returns 1 in the field. If you swap it out with \2, it will return 2.
It should return the value found between the ( ) into the new_data_field, as it successfully matches on that pattern against that fields values.
That example does not match the behavior I am looking for. That is for a static replacement with a fixed value ‘XXX-XX’ when a field matches a REGEX pattern. Dremio performs this in the UI and with a hand coded use of REGEXP_REPLACE with ease.
However, Dremio is not recognizing substitution with the standards found in JAVA, PostgreSQL or Oracle for the REGEXP_REPLACE function where any number of matches included between parenthesis (.*) or (matchme I am a literal) are not populating in the ouput of the function into \1 or # of matched value reference.
Yes, the literal replacement with the match works just fine. Which is what the example above provides.
I don’t know if dealercrm saw either definition or just went with familiar regex syntax (it’s slightly different in practically every system), but it’d be nice if both places indicated that it’s java regex.