camelcasing

How to do CamelCase split in python

拈花ヽ惹草 提交于 2019-11-27 11:40:10
What I was trying to achieve, was something like this: >>> camel_case_split("CamelCaseXYZ") ['Camel', 'Case', 'XYZ'] >>> camel_case_split("XYZCamelCase") ['XYZ', 'Camel', 'Case'] So I searched and found this perfect regular expression : (?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z]) As the next logical step I tried: >>> re.split("(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])", "CamelCaseXYZ") ['CamelCaseXYZ'] Why does this not work, and how do I achieve the result from the linked question in python? Edit: Solution summary I tested all provided solutions with a few test cases: string: ''

Acronyms in CamelCase [closed]

余生颓废 提交于 2019-11-27 10:03:59
I have a doubt about CamelCase. Supose you have this acronym: Unesco = United Nations Educational, Scientific and Cultural Organization. You should write: unitedNationsEducationalScientificAndCulturalOrganization But what if you need to write the acronym? Something like: getUnescoProperties(); Is it right to write it this way? getUnescoProperties() OR getUNESCOProperties(); Apollo SOFTWARE Some guidelines Microsoft has written about camelCase are: When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton . However,

How to navigate through the source code by parts in CamelCase (instead of whole words)?

纵饮孤独 提交于 2019-11-27 09:12:59
问题 I remember when I was using Eclipse that when holding CTRL and using left or right arrows Eclipse would navigate over the LongCamelCaseWrittenWord in several steps. One camel case word at time. So it will go like follows (pipe | represents the actual cursor position): |LongCamelCaseWrittenWord -> CTRL+RIGHT_ARROW -> Long|CamelCaseWrittenWord -> CTRL+RIGHT_ARROW -> LongCamel|CaseWrittenWord -> CTRL+RIGHT_ARROW -> LongCamelCase|WrittenWord -> CTRL+RIGHT_ARROW -> LongCamelCaseWritten|Word ->

Regex for CamelCased words with leading uppercase letter

浪尽此生 提交于 2019-11-27 07:48:35
How do I find all CamelCased words in a document with a regular expression? I'm only concerned with leading Upper camel case (i.e., camel cased words in which the first letter is capitalized). Adam Crume ([A-Z][a-z0-9]+)+ Assuming English. Use appropriate character classes if you want it internationalizable. This will match words such as "This". If you want to only match words with at least two capitals, just use ([A-Z][a-z0-9]+){2,} UPDATE: As I mentioned in a comment, a better version is: [A-Z]([A-Z0-9]*[a-z][a-z0-9]*[A-Z]|[a-z0-9]*[A-Z][A-Z0-9]*[a-z])[A-Za-z0-9]* It matches strings that

Convert JSON style properties names to Java CamelCase names with GSON

三世轮回 提交于 2019-11-26 18:55:42
问题 I'm using GSON to convert JSON data I get to a Java object. It works pretty well in all my tests. The problem is that our real objects have some properties named like is_online. GSON only maps them if they are named totally equal, it would be nice to have GSON convert the names to Java camel case isOnline. It seems this is possible while creating the JSON data, camel case is converted to underscore separated words in JSON. But I can't find a way to specify this the other way round. 回答1: I

Convert hyphens to camel case (camelCase)

跟風遠走 提交于 2019-11-26 18:52:08
问题 With regex (i assume) or some other method, how can i convert things like: marker-image or my-example-setting to markerImage or myExampleSetting . I was thinking about just splitting by - then convert the index of that hypen +1 to uppercase. But it seems pretty dirty and was hoping for some help with regex that could make the code cleaner. No jQuery... 回答1: Try this: var camelCased = myString.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }); The regular expression will match

How can I return camelCase JSON serialized by JSON.NET from ASP.NET MVC controller methods?

血红的双手。 提交于 2019-11-26 18:27:26
My problem is that I wish to return camelCased (as opposed to the standard PascalCase) JSON data via ActionResult s from ASP.NET MVC controller methods, serialized by JSON.NET . As an example consider the following C# class: public class Person { public string FirstName { get; set; } public string LastName { get; set; } } By default, when returning an instance of this class from an MVC controller as JSON, it'll be serialized in the following fashion: { "FirstName": "Joe", "LastName": "Public" } I would like it to be serialized (by JSON.NET) as: { "firstName": "Joe", "lastName": "Public" } How

Acronyms in CamelCase [closed]

房东的猫 提交于 2019-11-26 17:55:19
问题 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 last year . I have a doubt about CamelCase. Supose you have this acronym: Unesco = United Nations Educational, Scientific and Cultural Organization. You should write: unitedNationsEducationalScientificAndCulturalOrganization But what if you need to write the acronym? Something like:

linux bash, camel case string to separate by dash

浪尽此生 提交于 2019-11-26 16:25:39
问题 Is there a way to convert something like this: MyDirectoryFileLine to my-directory-file-line I found some ways to convert all letters to uppercase or lowercase, but not in that way; any ideas? 回答1: You can use s/\([A-Z]\)/-\L\1/g to find an upper case letter and replace it with a dash and it's lower case. However, this gives you a dash at the beginning of the line, so you need another sed expression to handle that. This should work: sed --expression 's/\([A-Z]\)/-\L\1/g' \ --expression 's/^-/

How to do CamelCase split in python

耗尽温柔 提交于 2019-11-26 15:34:54
问题 What I was trying to achieve, was something like this: >>> camel_case_split("CamelCaseXYZ") ['Camel', 'Case', 'XYZ'] >>> camel_case_split("XYZCamelCase") ['XYZ', 'Camel', 'Case'] So I searched and found this perfect regular expression: (?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z]) As the next logical step I tried: >>> re.split("(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])", "CamelCaseXYZ") ['CamelCaseXYZ'] Why does this not work, and how do I achieve the result from the linked question in