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

Formating for pcre regx patterns #123

Open
photodude opened this issue Dec 11, 2015 · 1 comment
Open

Formating for pcre regx patterns #123

photodude opened this issue Dec 11, 2015 · 1 comment

Comments

@photodude
Copy link
Contributor

After some performance testing and consideration for readability, I think that patterns like [0-9] or [[:digit:]] is better than \d as the meaning is more clear. Since there seems to be no performance difference between any of these patterns; readability is prefered over the more condensed version.

Expression Meaning Prefered option 1 Prefered option 2
\d any decimal digit [0-9] [[:digit:]]
\D any character that is not a decimal digit [^0-9] --
\w any alphanumeric character (aka word character) [a-zA-Z0-9_] [[:word:]]
[a-z] Lowercase letters [a-z] [[:lower:]]
[A-Z] Uppercase letters [A-Z] [[:upper:]]
\xYY Hexadecimal character YY [0-9a-fA-F] [[:xdigit:]]

Preference to readability for pcre/regx patterns should be included in the coding standard.

@photodude
Copy link
Contributor Author

I think something should be done in regards to a rule for pcre regx patterns. but as I don't have the time or skills to address I will Suggest voting to close as a Stale issue. @wilsonge @mbabker

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

1 participant