camelcasing

Regex that matches Camel and Pascal Case

ε祈祈猫儿з 提交于 2019-12-04 09:20:35
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? camelCase: ^[a-z]+(?:[A-Z][a-z]+)*$ PascalCase: ^[A-Z][a-z]+(?:[A-Z][a-z]+)*$ /([A-Z][a-z]+)*[A-Z][a-z]*/ But I have to say your naming choice stinks, HTMLParser

How can I cut(1) camelcase words?

时间秒杀一切 提交于 2019-12-04 03:31:21
Is there an easy way in Bash to split a camelcased word into its constituent words? For example, I want to split aCertainCamelCasedWord into 'a Certain Camel Cased Word' and be able to select those fields that interest me. This is trivially done with cut(1) when the word separator is the underscore, but how can I do this when the word is camelcased? sed 's/\([A-Z]\)/ \1/g' Captures each capital letter and substitutes a leading space with the capture for the whole stream. $ echo "aCertainCamelCasedWord" | sed 's/\([A-Z]\)/ \1/g' a Certain Camel Cased Word gerardw This solution works if you need

How do I convert an NSString from CamelCase to TitleCase, 'playerName' into 'Player Name'?

☆樱花仙子☆ 提交于 2019-12-04 00:18:33
I'm looking for the easiest way to convert a string from camelback format to Title Case format. How do I change 'playerName' into 'Player Name'? NSString *str = @"playerName"; NSMutableString *str2 = [NSMutableString string]; for (NSInteger i=0; i<str.length; i++){ NSString *ch = [str substringWithRange:NSMakeRange(i, 1)]; if ([ch rangeOfCharacterFromSet:[NSCharacterSet uppercaseLetterCharacterSet]].location != NSNotFound) { [str2 appendString:@" "]; } [str2 appendString:ch]; } NSLog(@"%@", str2.capitalizedString); Here's a simpler Swift version. I've chucked it into an extension extension

CamelCase Expansion in Vim like Intellij Idea?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 13:48:57
问题 In Intellij Idea, there's a feature. Let's say I have used a variable myCamelCase somewhere in my code. Then if I type mCC and press Ctrl - Enter or some such key combination, it expands to myCamelCase . Is there something similar in Vim? 回答1: Okay, forgive me for answering twice, but since my first attempt missed the point, I'll have another go. This is more complicated than I thought, but possibly not as complicated as I have made it (!). This is now modified to suggest all matching

For what reason do we have the lower_case_with_underscores naming convention? [closed]

社会主义新天地 提交于 2019-12-03 12:04:40
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . Depending on your interpretation this may or may not be a rhetorical question, but it really baffles me. What sense does this convention make? I understand naming conventions don't necessarily have to have a rhyme or reason behind them, but why deviate from the already

Underscores or camelCase in PostgreSQL identifiers, when the programming language uses camelCase?

会有一股神秘感。 提交于 2019-12-03 10:29:22
问题 This has been bothering me for a while, and I can't arrive at a solution that feels right ... Given an OO language in which the usual naming convention for object properties is camelCased, and an example object like this: { id: 667, firstName: "Vladimir", lastName: "Horowitz", canPlayPiano: true } How should I model this structure in a PostgreSQL table? There are three main options: unquoted camelCase column names quoted camelCase column names unquoted (lowercase) names with underscores They

What are the different kinds of cases?

删除回忆录丶 提交于 2019-12-03 03:31:06
问题 I'm interested in the different kinds of identifier cases, and what people call them. Do you know of any additions to this list, or other alternative names? myIdentifier : Camel case (e.g. in java variable names) MyIdentifier : Capital camel case (e.g. in java class names) my_identifier : Snake case (e.g. in python variable names) my-identifier : Kebab case (e.g. in racket names) myidentifier : Flat case (e.g. in java package names) MY_IDENTIFIER : Upper case (e.g. in C constant names) 回答1:

Convert CamelCase to under_score_case in php __autoload()

天大地大妈咪最大 提交于 2019-12-03 03:10:06
问题 PHP manual suggests to autoload classes like function __autoload($class_name){ require_once("some_dir/".$class_name.".php"); } and this approach works fine to load class FooClass saved in the file my_dir/FooClass.php like class FooClass{ //some implementation } Question How can I make it possible to use _autoload() function and access FooClass saved in the file my_dir/foo_class.php ? 回答1: You could convert the class name like this... function __autoload($class_name){ $name = strtolower(preg

Underscores or camelCase in PostgreSQL identifiers, when the programming language uses camelCase?

孤人 提交于 2019-12-03 00:54:40
This has been bothering me for a while, and I can't arrive at a solution that feels right ... Given an OO language in which the usual naming convention for object properties is camelCased, and an example object like this: { id: 667, firstName: "Vladimir", lastName: "Horowitz", canPlayPiano: true } How should I model this structure in a PostgreSQL table? There are three main options: unquoted camelCase column names quoted camelCase column names unquoted (lowercase) names with underscores They each have their drawbacks: Unquoted identifiers automatically fold to lowercase. This means that you

Convert CamelCase to under_score_case in php __autoload()

佐手、 提交于 2019-12-02 17:41:14
PHP manual suggests to autoload classes like function __autoload($class_name){ require_once("some_dir/".$class_name.".php"); } and this approach works fine to load class FooClass saved in the file my_dir/FooClass.php like class FooClass{ //some implementation } Question How can I make it possible to use _autoload() function and access FooClass saved in the file my_dir/foo_class.php ? You could convert the class name like this... function __autoload($class_name){ $name = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $class_name)); require_once("some_dir/".$name.".php"); } This is