-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_parser_test.go
More file actions
59 lines (51 loc) · 1.33 KB
/
Copy pathexample_parser_test.go
File metadata and controls
59 lines (51 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package strings2_test
import (
"fmt"
"github.com/arran4/strings2"
)
func ExampleWithNumberMode() {
input := "user123profile"
// Using WithNumberMode to split at digits
words, _ := strings2.Parse(input, strings2.WithNumberMode(strings2.NumberModeSplitAlways))
fmt.Println(words)
// Output: [user 123 profile]
}
func ExampleWithSmartAcronyms() {
input := "XMLReader"
// Using WithSmartAcronyms to separate XML from Reader
words, _ := strings2.Parse(input, strings2.WithSmartAcronyms(true))
fmt.Println(words)
// Output: [XML Reader]
}
func ExampleParseSnakeCase() {
input := "hello_world"
// ParseSnakeCase assumes a snake case structure
words, _ := strings2.ParseSnakeCase(input)
fmt.Println(words)
// Output: [hello world]
}
func ExampleWithIgnore() {
words, _ := strings2.Parse("some.kind.of.example", strings2.WithIgnore("."))
res, _ := strings2.ToScreamingDelimitedCase(words, '.', ".", true)
fmt.Println(res)
// Output:
// SOME.KIND.OF.EXAMPLE
}
func ExampleParseToParts() {
parts, _ := strings2.ParseToParts("hello_world", strings2.WithSnakeCasePartitioner())
for _, p := range parts {
fmt.Println(p.String())
}
// Output:
// hello
// world
}
func ExampleParseTitleCase() {
words, _ := strings2.ParseTitleCase("Hello World")
for _, w := range words {
fmt.Println(w.String())
}
// Output:
// Hello
// World
}