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

Support for flags #13

Open
titanism opened this issue Oct 30, 2023 · 2 comments
Open

Support for flags #13

titanism opened this issue Oct 30, 2023 · 2 comments

Comments

@titanism
Copy link

There's a comment here but it seems unrelated to the code

// regex(pattern [, flags])
pub fn regex_print(context: *mut sqlite3_context, values: &[*mut sqlite3_value]) -> Result<()> {
. Does this lib support flags? (e.g. i)

@titanism
Copy link
Author

Looks like we can set it such as REGEXP '(?i)LINUS with (?i) in the regex itself, e.g. to match linus, Linus, LINUS, etc. Having a flag would be great too somehow (?)

@asg017
Copy link
Owner

asg017 commented Oct 30, 2023

Yeah, the (?i) syntax is the current way to define flags, like:

select 
  value, 
  value regexp '(?i)linus' ,
  value regexp 'linus'
from json_each('["linus", "Linus", "LINUS", "moo"]');

/*
┌───────┬──────────────────────────┬──────────────────────┐
│ value │ value regexp '(?i)linus' │ value regexp 'linus' │
├───────┼──────────────────────────┼──────────────────────┤
│ linus │ 1                        │ 1                    │
│ Linus │ 1                        │ 0                    │
│ LINUS │ 1                        │ 0                    │
│ moo   │ 0                        │ 0                    │
└───────┴──────────────────────────┴──────────────────────┘
*/

The underlying Rust regex crate doesn't offer a way to define flags in any other way. I may also add a new regexpi() function that'll implicitly add the ignore flag in the next reelase.

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