GPAL - Generally Positive Automation Library
v1.0
GPAL The Fluent Automation LIbrary
Toggle main menu visibility
Loading...
Searching...
No Matches
stringExtension.cs
1
// =============================================================================
2
// GPAL - Generally Positive Automation Library
3
// Copyright © 2026 Software Decisions, Inc. All rights reserved.
4
//
5
// This file is part of GPAL.
6
// Licensed under the Business Source License 1.1
7
//
8
// Primary development, architecture, and vision by Michael B. Vederman,
9
// CEO of Software Decisions, Inc., Texas.
10
//
11
// Internal development maintained privately.
12
// Public releases appear on GitHub: https://github.com/SoftwareDecisionsInc/GPAL.
13
//
14
// See LICENSE for full terms, including Additional Use Grant.
15
// =============================================================================
16
17
using
Newtonsoft.Json;
18
using
System;
19
using
System.Collections.Generic;
20
using
System.Linq;
21
using
System.Text;
22
using
System.Text.RegularExpressions;
23
using
System.Threading.Tasks;
24
25
namespace
GenerallyPositive
26
{
27
// https://code-maze.com/csharp-convert-string-titlecase-camelcase/
28
public
static
class
stringExtension
29
{
30
public
static
string
ToCamelCase(
this
string
str)
31
{
32
var words = str.Split(
new
[] {
"_"
,
" "
}, StringSplitOptions.RemoveEmptyEntries);
33
var leadWord = Regex.Replace(words[0],
@"([A-Z])([A-Z]+|[a-z0-9]+)($|[A-Z]\w*)"
,
34
m =>
35
{
36
return
m.Groups[1].Value.ToLower() + m.Groups[2].Value.ToLower() + m.Groups[3].Value;
37
});
38
var tailWords = words.Skip(1)
39
.Select(word =>
char
.ToUpper(word[0]) + word.Substring(1))
40
.ToArray();
41
return
$
"{leadWord}{string.Join(string.Empty, tailWords)}"
;
42
}
43
}
44
}
45
GenerallyPositive
Definition
Application.cs:32
Common
stringExtension.cs
Generated by
1.17.0