Open
Conversation
Member
|
Can you compare this with how |
Author
#[cfg(test)]
mod tests {
use regex::Regex;
#[test]
fn test_regex_lite() {
let hyphen_pattern = "(?x)[0-#-contrived comment!\n9]+";
let right_square_bracket_pattern = "(?x)[0-#]contrived comment!\n9]+";
let another_pattern = "(?x)[0-# contrived comment!\n9]+";
let haystack = "0123456789";
let hyphen_match = Regex::new(hyphen_pattern).unwrap().find(haystack).unwrap();
let right_square_bracket_match = Regex::new(right_square_bracket_pattern)
.unwrap()
.find(haystack)
.unwrap();
let another_match = Regex::new(another_pattern).unwrap().find(haystack).unwrap();
assert_eq!(hyphen_match, right_square_bracket_match);
assert_eq!(hyphen_match, another_match);
}
} |
Author
|
test codes are basically the same, it seems that the behavior of regex and regex-lite is consistent |
YydsNone
commented
Jul 28, 2024
| self.pattern()[start..].chars().next() | ||
| let char_offset = self.pattern[start..].chars().position(|ch| { | ||
| let ori_in_command = in_comment; | ||
| // detailed representation: (in_comment && ch != '\n') || (!in_comment || ch == '#') |
Author
There was a problem hiding this comment.
(!in_commit || ch == '#') -> (!in_commit && ch == '#')
Member
I can't tell whether you're talking about them being consistent before or after this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm now using regex-lite@0.1.6 and noticed that pattern
(?x)[0-#-contrived comment!\n9]+and pattern(?x)[0-# contrived comment!\n9]+behave differently. I think the cause is that Parser'speek_spacemethod doesn't skip comment correctly (not consistent withbump_spacemethod). below is a simple comparison between(?x)[0-#-contrived comment!\n9]+,(?x)[0-#]contrived comment!\n9]+and(?x)[0-# contrived comment!\n9]+.