Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fn:replace: Combine $replacement and $action parameters #1876

Open
ChristianGruen opened this issue Mar 14, 2025 · 2 comments
Open

fn:replace: Combine $replacement and $action parameters #1876

ChristianGruen opened this issue Mar 14, 2025 · 2 comments
Assignees
Labels
Enhancement A change or improvement to an existing feature XQFO An issue related to Functions and Operators

Comments

@ChristianGruen
Copy link
Contributor

We could combine the competing $replacement and $action parameters:

replace(
  'this is a test',
  '(\w)(\w+)?',
  fn($s, $g) { upper-case($g[1]) || lower-case($g[2]) }
)

Original comment: #1863 (comment)

@ChristianGruen ChristianGruen added Enhancement A change or improvement to an existing feature XQFO An issue related to Functions and Operators labels Mar 14, 2025
@ChristianGruen ChristianGruen self-assigned this Mar 14, 2025
@liamquin
Copy link
Contributor

+1 to this.

@michaelhkay
Copy link
Contributor

michaelhkay commented Mar 16, 2025

The text also need to be revised to make it clear that when there are multiple matches, the replacement string can be different for each match, because each match will (in general) have different captured groups.

PR #1856 makes significant changes to the text of fn:replace, so I propose to wait until that has been applied before raising a PR for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement A change or improvement to an existing feature XQFO An issue related to Functions and Operators
Projects
None yet
Development

No branches or pull requests

3 participants