Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
robinst merged 31 commits intofancy-regex:mainfromhugopendlebury:main
Jun 30, 2025

Conversation

hugopendlebury
Copy link
Contributor

See
#98

Copy link
Contributor

@keith-hallkeith-hall left a 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...

hugopendleburyand others added4 commitsJune 24, 2025 06:26
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
@keith-hall
Copy link
Contributor

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,fancy-regex parses the pattern (without knowing about ignore whitespace mode for example), then if it contains fancy features, builds a VM and delegates some parts of the matching toregex-automata. But this means that if users/consumers start relying on these new options, some regular expressions will be matched incorrectly.
Concrete example - this test panics when it shouldn't:

#[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
Copy link
ContributorAuthor

hugopendlebury commentedJun 24, 2025
edited
Loading

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.
With has nodes such as.

Literal {    /// The string to match    val: String,    /// Whether match is case-insensitive or not    casei: bool,},

Would it be crazy to use to this AST / modify this tree ?

e.g. with this example

RegexBuilder::new(r"hello")
.case_insensitive(true)
.build();

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
e.g. (?i)hello would be passed.

@keith-hall
Copy link
Contributor

Wrapping nodes in(?i) should already be handled by the code which delegates to regex-automata. The main thing we need to achieve is, as you say, getting the AST correct. We should be able to do this by setting initial flags when parsing the regex pattern into an AST.

@hugopendlebury
Copy link
ContributorAuthor

Wrapping nodes in(?i) should already be handled by the code which delegates to regex-automata. The main thing we need to achieve is, as you say, getting the AST correct. We should be able to do this by setting initial flags when parsing the regex pattern into an AST.

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.

Copy link
Contributor

@keith-hallkeith-hall left a 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 🙂

@keith-hallkeith-hall requested a review fromrobinstJune 25, 2025 18:35
@hugopendlebury
Copy link
ContributorAuthor

Thanks@keith-hall.

Yeah I agree and commented as much. Let me see if there is some way to address that.

hugopendleburyand others added3 commitsJune 26, 2025 19:02
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
Copy link
Contributor

@robinstrobinst left a 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.

Copy link
Contributor

@robinstrobinst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM now, thanks!

@robinstrobinst merged commit66a3f90 intofancy-regex:mainJun 30, 2025
9 checks passed
@robinst
Copy link
Contributor

@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 :).

keith-hall reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@keith-hallkeith-hallkeith-hall approved these changes

@robinstrobinstrobinst approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@hugopendlebury@keith-hall@robinst

[8]ページ先頭

©2009-2025 Movatter.jp