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

Add select * from regex_captures #1

Open
asg017 opened this issue Jan 19, 2023 · 1 comment
Open

Add select * from regex_captures #1

asg017 opened this issue Jan 19, 2023 · 1 comment

Comments

@asg017
Copy link
Owner

asg017 commented Jan 19, 2023

Using .captures_iter

@greatvovan
Copy link

As I understand, you are proposing a table function. Are you planing to expose capturing groups as rows or columns? How do you envision it's usage in cases like

... ID123Y2023ABC ...

Say, I need to select ID and year as columns. If you return groups as columns, I could write something like

SELECT (SELECT g1 from regex_captures(my_field, 'ID(d+)Y(d+)ABC') as ID,
  (SELECT g2 from regex_captures(my_field, 'ID(d+)Y(d+)ABC') as year
FROM my_table

It looks like we are going to call the function twice with the same arguments. Is that what you going to do or you have a simpler solution?

Also I am thinking if it makes sense to have a scalar version of the function, like regex_capture(input, regex, group_num)? It is still unclear though how to select multiple groups into different columns from a single source.

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

No branches or pull requests

2 participants