Go Package regexp: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 7: Line 7:


* [[Go_Language_Modularization#regexp|Standard Library]]
* [[Go_Language_Modularization#regexp|Standard Library]]
* [[Go_Regular_Expressions#Overview|Go Regular Expressions]]


=Overview=
=Overview=

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]

Functions

regexp.MatchString()

TODO