Go Package regexp

From NovaOrdis Knowledge Base
Revision as of 01:36, 11 January 2024 by Ovidiu (talk | contribs) (→‎Internal)
Jump to navigation Jump to search

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()