[ 
https://issues.apache.org/jira/browse/FLINK-34477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18104813#comment-18104813
 ] 

Gustavo de Morais commented on FLINK-34477:
-------------------------------------------

This also matters for performance, not just ergonomics. Without capture groups, 
an "insert text here" rewrite has to be expressed as a zero-width lookaround 
with a variable-length lookbehind, which Java brute-forces at every position. 

On the approach: changing {{REGEXP_REPLACE}} in place is a breaking change. A 
4th argument is a possibility but a bit ugly. Probably safer and cleaner to add 
a new function than to change the existing one.

> support capture groups in REGEXP_REPLACE
> ----------------------------------------
>
>                 Key: FLINK-34477
>                 URL: https://issues.apache.org/jira/browse/FLINK-34477
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / API
>    Affects Versions: 1.18.1
>            Reporter: David Anderson
>            Assignee: Jeyhun Karimov
>            Priority: Major
>              Labels: pull-request-available
>
> For example, I would expect this query
> {code:java}
> select REGEXP_REPLACE('ERR1,ERR2', '([^,]+)', 'AA$1AA'); {code}
> to produce
> {code:java}
> AAERR1AA,AAERR2AA{code}
> but instead it produces
> {code:java}
> AA$1AA,AA$1AA{code}
> With FLINK-9990 support was added for REGEXP_EXTRACT, which does provide 
> access to the capture groups, but for many use cases supporting this in the 
> way that users expect, in REGEXP_REPLACE, would be more natural and 
> convenient.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to