Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Merge requests
!15
Resolve "Create SnakeToKebabString util function"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Resolve "Create SnakeToKebabString util function"
23-create-snaketokebabstring-util-function
into
main
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Francé Wilke
requested to merge
23-create-snaketokebabstring-util-function
into
main
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Related to
#23 (closed)
Edited
3 years ago
by
Francé Wilke
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
f7c26eb8
1 commit,
3 years ago
1 file
+
13
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
string_utils/snake.go
+
13
−
1
View file @ f7c26eb8
Edit in single-file editor
Open in Web IDE
Show full file
package
string_utils
import
"regexp"
import
(
"regexp"
"strings"
)
const
snakeCasePattern
=
`[a-z]([a-z0-9_]*[a-z0-9])*`
@@ -9,3 +12,12 @@ var snakeCaseRegex = regexp.MustCompile("^" + snakeCasePattern + "$")
func
IsSnakeCase
(
name
string
)
bool
{
return
snakeCaseRegex
.
MatchString
(
name
)
}
func
SnakeToKebabString
(
s
string
)
string
{
s
=
strings
.
TrimSpace
(
s
)
re
:=
regexp
.
MustCompile
(
"(_)"
)
s
=
re
.
ReplaceAllString
(
s
,
"-"
)
return
s
}
Loading