Fix incorrect regex on Person.name field#1089
Merged
rodaine merged 3 commits intobufbuild:mainfrom Mar 25, 2024
Merged
Conversation
The example regular expression introduced in bufbuild@10eb9db does not seem to work as intended, due to nesting a negated range inside another range: ``` ❯ jshell --class-path ~/.m2/repository/com/google/re2j/re2j/1.7/re2j-1.7.jar | Welcome to JShell -- Version 17.0.9 | For an introduction type: /help intro jshell> com.google.re2j.Pattern p = com.google.re2j.Pattern.compile("^[^[0-9]A-Za-z]+( [^[0-9]A-Za-z]+)*$"); p ==> ^[^[0-9]A-Za-z]+( [^[0-9]A-Za-z]+)*$ jshell> p.matches(pattern, "Protocol Buffers"); $4 ==> false jshell> p.matches(pattern, "Matt Brown"); $5 ==> false ``` The nesting of ranges in the example is also redundant - if you are going to specify that only `[A-Za-z]` is valid than including [^0-9]` in that range is not necessary. This commit fixes the example regular expression to match the example "name" mentioned later in the README.
Member
|
Hey, @mattnworb, and thanks for the patch! Hm, looks like at some point it was made inconsistent with the regex that was originally in the readme: |
Contributor
Author
Contributor
Author
|
noticed an occurrence of the regex used in |
Member
|
Looks good! Once you sign the CLA we can get this merged 😁 |
Contributor
Author
|
done, thanks! |
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.
The example regular expression introduced in 10eb9db does not seem to work as intended, due to nesting a negated range inside another range:
The nesting of ranges in the example is also redundant - if you are going to specify that only
[A-Za-z]is valid than including [^0-9]` in that range is not necessary.This commit fixes the example regular expression to match the example "name" mentioned later in the README.