I'm about to write a parser for a language that's supposed to have strict syntactic rules about naming of types, variables and such. For example all classes must be PascalCase, and all variables/parameter names and other identifiers must be camelCase.
For example HTMLParser
is not allowed and must be named HtmlParser
. Any ideas for a regexp that can match something that is PascalCase, but does not have two capital letters in it?
Camel case and Pascal case are similar. Both demand variables made from compound words and have the first letter of each appended word written with an uppercase letter. The difference is that Pascal case requires the first letter to be uppercase as well, while camel case does not.
Camel Case (camelCase): In this standard, the first letter of the word always in small letter and after that each word starts with a capital letter. Pascal Case (PascalCase): In this the first letter of every word is in capital letter.
Meaning of camel case in English. the use of a capital letter to begin the second word in a compound name or phrase, when it is not separated from the first word by a space: Examples of camel case include "iPod" and "GaGa." Want to learn more?
camelCase:
^[a-z]+(?:[A-Z][a-z]+)*$
PascalCase:
^[A-Z][a-z]+(?:[A-Z][a-z]+)*$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With