Simple Pattern Matching
Test whether a pattern matches a string:Compiled Patterns
For other regexp tasks, compile an optimizedRegexp struct:
Finding Matches
Finding All Matches
TheAll variants find all matches in the input:
Byte Arguments
Provide[]byte arguments and drop String from the function name:
MustCompile for Globals
UseMustCompile for global variables. It panics instead of returning an error:
String Replacement
Replace matched substrings:Transform with Functions
UseFunc variants to transform matched text:
Common Methods
MatchString - Test match
MatchString - Test match
Returns true if the pattern matches the string
FindString - Find first match
FindString - Find first match
Returns the leftmost match of the pattern
FindAllString - Find all matches
FindAllString - Find all matches
Returns all matches of the pattern
ReplaceAllString - Replace matches
ReplaceAllString - Replace matches
Replaces matches with a replacement string
ReplaceAllFunc - Transform matches
ReplaceAllFunc - Transform matches
Transforms matches using a function