Go Package regexp: Difference between revisions
Jump to navigation
Jump to search
Line 35: | Line 35: | ||
* <tt>[https://golang.org/pkg/regexp/#MatchString regexp.MatchString()]</tt> | * <tt>[https://golang.org/pkg/regexp/#MatchString regexp.MatchString()]</tt> | ||
=TODO= | |||
* https://blog.logrocket.com/deep-dive-regular-expressions-golang/ | |||
* https://gobyexample.com/regular-expressions |
Revision as of 01:38, 11 January 2024
External
Internal
Overview
import (
"regexp"
)
var someRegexp *regexp.Regexp
someRegexp = regexp.MustCompile("(\\D+)(\\d+),(\\d)")
groups := someRegexp.FindSubmatch([]byte(s))
if groups == nil {
// no match
...
}
entireString := groups[0]
firstGroup := groups[1]
secondGroup := groups[2]
thirdGroup := groups[3]