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

[Feature][SDK] Transform support REGEXP_MATCHES(str, pattern) function #10986

Closed
2 tasks done
emptyOVO opened this issue Sep 2, 2024 · 0 comments · Fixed by #10993
Closed
2 tasks done

[Feature][SDK] Transform support REGEXP_MATCHES(str, pattern) function #10986

emptyOVO opened this issue Sep 2, 2024 · 0 comments · Fixed by #10993
Assignees
Milestone

Comments

@emptyOVO
Copy link
Contributor

emptyOVO commented Sep 2, 2024

Description

parent: #10796

  • REGEXP_MATCHES(str, pattern): a powerful function in PostgreSQL that matches regular expression patterns in strings and returns all matched results

Use case

  • Matching a single pattern:
    Let's say we have a string from which we want to extract substrings that match a particular pattern
    REGEXP_MATCHES('The quick brown fox', 'quick')--returns {quick}
  • Extract multiple subpatterns
    Multiple substrings can be extracted using capture groups in regular expressions
    REGEXP_MATCHES('User: Alice, ID: 12345', 'User: (\w+), ID: (\d+)')--returns {Alice,12345}
  • Globally match multiple patterns
    The g flag can be used when you want to match all the substrings that occur
    REGEXP_MATCHES('foo 123 bar 456', '\d+', 'g')--returns {"123","456"}
  • Case matching is ignored
    Use the i flag to ignore case for matching
    REGEXP_MATCHES('Hello World', 'hello', 'i')--returns {Hello}
  • Multi-line pattern matching
    Using the m flag allows regular expressions to match across multiple lines
    REGEXP_MATCHES('First line\nSecond line', '^Second', 'm')--returns {Second}
  • Some Announcements:
    REGEXP_MATCHES() returns an array, so be careful about using arrays when processing the results.
    If the global flag g is not used, only the first matching substring is returned.

Are you willing to submit PR?

  • Yes, I am willing to submit a PR!

Code of Conduct

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

Successfully merging a pull request may close this issue.

2 participants