Last active
July 13, 2019 06:21
-
-
Save LwServices/3fa5c3164f915b8022d6a4ba247db105 to your computer and use it in GitHub Desktop.
SNAKE_CASE to PascalCase
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
var InString = "bla_BLA_bla"; | |
var patternUpperCamelCase = @"(^|[_-])([a-zA-Z0-9])([a-zA-Z0-9]+)"; | |
var pattern2 = @"((?<First>^[a-zA-Z0-9])|(?<Separator>[_-]|\s)(?<Next>[a-zA-Z0-9]))(?<Body>[a-zA-Z0-9]{0,})"; | |
var pattern = @"((?<First>^[a-zA-Z0-9])|(?<Separator>[^a-zA-Z0-9]|\s)+(?<Next>[a-zA-Z0-9]))(?<Body>[a-zA-Z0-9]{0,})"; | |
var result = Regex.Replace(InString, pattern, match => | |
{ | |
var sb = new StringBuilder(); | |
if (match.Groups["First"].Success) | |
{ | |
sb.Append("_"); | |
sb.Append(match.Groups["First"].Value.ToLower()); | |
} | |
if (match.Groups["Next"].Success) | |
{ | |
sb.Append(match.Groups["Next"].Value.ToUpper()); | |
} | |
if (match.Groups["Body"].Success) | |
{ | |
sb.Append(match.Groups["Body"].Value.ToLower()); | |
} | |
return sb.ToString(); | |
}); | |
https://stacktoheap.com/blog/2013/01/20/using-typeconverters-to-get-appsettings-in-net/ | |
"C:\Program Files\7-Zip\7z.exe" a -tzip archive.zip * [email protected] | |
obj | |
debug | |
bin | |
packages | |
*.obj | |
*.dll | |
*.exe | |
*.zip | |
*.suo | |
.vs | |
archive.ignored | |
archive.bat | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment