Skip to content

Conversation

@GaneshPatil7517
Copy link
Contributor

@GaneshPatil7517 GaneshPatil7517 commented Jan 15, 2026

The regex_replace_posix_groups method was using the pattern (\d*) to match
POSIX capture group references like \1. However, * matches zero or more
digits, which caused a lone backslash \ to incorrectly become ${}.

Changed to (\d+) which requires at least one digit, fixing the issue.

Added unit tests to validate correct behavior.

The regex pattern was using (\d*) which matches zero or more digits,
causing a lone backslash to be incorrectly converted to ${}. Changed
to (\d+) which requires at least one digit, ensuring only actual POSIX
capture group references like \1, \2, etc. are converted to , .

Added unit tests to verify the correct behavior.
Copilot AI review requested due to automatic review settings January 15, 2026 11:04
@github-actions github-actions bot added the functions Changes to functions implementation label Jan 15, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the regex_replace_posix_groups function where the regex pattern (\d*) incorrectly matched zero or more digits, causing a lone backslash \ to be transformed into ${}. The fix changes the pattern to (\d+) to require at least one digit.

Changes:

  • Modified the regex pattern in regex_replace_posix_groups from (\d*) to (\d+) to match one or more digits
  • Added comprehensive unit tests to validate the fix and prevent regression

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@xanderbailey xanderbailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix. Thanks for the PR. This looks correct to me but I don't have approval permissions!

The regex pattern was only matching single backslash (\1) but SQL string
literals with escaped backslashes pass through as double backslash (\\1).
Changed the pattern from (\\)(\d+) to \\{1,2}(\d+) to match 1 or 2
backslashes followed by digits, ensuring proper handling of SQL escaped
backreferences like 'X\\1Y'.

Added unit tests for the double backslash case.
@kumarUjjawal
Copy link
Contributor

Hi @GaneshPatil7517 Thank you for contribution. Please try to use the PR templates instead of the manual descriptions, it will allow the reviewers to easily understand the context.

@GaneshPatil7517
Copy link
Contributor Author

Hi @GaneshPatil7517 Thank you for contribution. Please try to use the PR templates instead of the manual descriptions, it will allow the reviewers to easily understand the context.

ok sir ill follow from you instruction....

@alamb
Copy link
Contributor

alamb commented Jan 15, 2026

FYI @shivbhatia10 -- is there any chance you would like to help review this PR too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect regex pattern in regex_replace_posix_groups

4 participants