Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0.11
Description
select regexp_replace('1 foo and bar', '(\\d+) foo and (\\d+ )?bar', '\\1 this and \\2that') |
expected result: 1 this and that
actual result: 1 this and 2that
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Description |
select regexp_replace('1 foo and bar', '(\\d+) foo and (\\d+ )?bar', '\\1 this and \\2that') expected result: 1 this and that actual result: 1 this and 2that |
{code:sql} select regexp_replace('1 foo and bar', '(\\d+) foo and (\\d+ )?bar', '\\1 this and \\2that') {code} expected result: 1 this and that actual result: 1 this and 2that |
Assignee | Alexander Barkov [ bar ] |
Fix Version/s | 10.0 [ 16000 ] |
Fix Version/s | 10.0.15 [ 17300 ] | |
Fix Version/s | 10.0 [ 16000 ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Workflow | MariaDB v2 [ 56718 ] | MariaDB v3 [ 65270 ] |
Workflow | MariaDB v3 [ 65270 ] | MariaDB v4 [ 148369 ] |
Thinking about it, it sort of makes sense.
the second group does not match to an empty value, it is undefined at all; so the ambiguous sequence backslash-backslash-2 defaults to '2'.
It's counter-intuitive though.
My quick search through PCRE documentation hasn't found anything saying whether it's intentional, so I'm assigning it to bar to confirm (or not).
Or, maybe there is a flag that controls it, I haven't found one either.