Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork41
Add multiline option and ignore space#165
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
In general this seems fine, I have made a few small comments, however.
Also, please note that in light of#163, it is possible that these builder methods won't take effect on all regex patterns... I think it depends whether the pattern is fully compatible with regex-automata or whether it uses fancy features...
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
Thanks for the improvements! I am still personally a little hesitant to merge this for the reasons mentioned in#163 - these options are not taken into account by the parser. So, #[test]fncheck_ignore_whitespace_option_fancy(){let builder =RegexBuilder::new(r"(?=test foo)").ignore_whitespace(true).build();let test_text =r"testfoo";match builder{Ok(regex) =>assert!(regex.is_match(test_text).unwrap_or_default()), _ =>panic!("builder should be able to compile with ignore whitespace option"),}} This test doesn't panic when it should: #[test]fncheck_ignore_whitespace_option_fancy_wrong(){let builder =RegexBuilder::new(r"(?=test foo)").ignore_whitespace(true).build();let test_text =r"test foo";match builder{Ok(regex) =>assert!(regex.is_match(test_text).unwrap_or_default()), _ =>panic!("builder should be able to compile with ignore whitespace option"),}} |
hugopendlebury commentedJun 24, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Ok I think I'm beginning to piece my head around what is going on. WRT to 163 - Passing the RegexOptions only has partial success, it appears to work on the email but doesn't help with the test case you mention here. I was wondering if a better approach might be to instead use the AST / Parsed Expression.
Would it be crazy to use to this AST / modify this tree ? e.g. with this example RegexBuilder::new(r"hello") Could the Tree be modified to consider any options ? Since the options would be set a global level ? Perhaps this could be then be used to modify the regex. I would imagine that in case a regex is determined to be "fancy" the tree is passed to the automata library and for simple regex the passed expression could be modified to include the option |
Wrapping nodes in |
Ok I think I've got a clearer understanding of more or less what is needed. I will park this for now and see if I can look more at 163 and the AST. Since that appears to be more of a key for things working consistently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This certainly solves the problem now, nice work, thanks for keeping at it. There are a few things that still make me hesitate a little, like makingRegexOptions
public and having the whole ofSyntaxConfig
passed to the parser when we only need certain flags. But, as it solves some very real issues, I would be tempted to say we could merge it and deal with those later, but let's see what@robinst thinks 🙂
Thanks@keith-hall. Yeah I agree and commented as much. Let me see if there is some way to address that. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for working on this! I have requested some changes. LGTM after those are addressed.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Robin Stocker <robinst@canva.com>
Co-authored-by: Robin Stocker <robinst@canva.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM now, thanks!
66a3f90
intofancy-regex:mainUh oh!
There was an error while loading.Please reload this page.
@keith-hall do you want to prepare a PR for doing the next release? I think you have the most changes to be documented in the CHANGELOG :). |
See
#98