package
main
import
(
f
"fmt"
"regexp"
)
func
main() {
f.Println(
"--------Reference strings--------\n"
)
name :=
"My name is Geeks for geeks."
f.Println(name)
profession :=
"I am a computer science portal for geeks."
f.Println(profession)
message :=
"You can find anything here, if not tell us and we'll add it for you!"
f.Println(message)
f.Println(
"\n--------Compiling functions--------\n"
)
musComp := regexp.MustCompile(
"[gG]ee.?"
)
f.Println(
"Initialized the regexp object to musComp..."
)
f.Println(
"\n--------Find functions--------\n"
)
f.Println(
"mustCompile.Find -----------------------> "
,
musComp.Find([]
byte
(name)))
f.Println(
"mustCompile.FindString -----------------> "
,
musComp.FindString(name))
f.Println(
"mustCompile.FindSubmatch ---------------> "
,
musComp.FindSubmatch([]
byte
(name)))
f.Println(
"mustCompile.FindStringSubmatch ---------> "
,
musComp.FindStringSubmatch(name))
f.Println(
"mustCompile.FindAll --------------------> "
,
musComp.FindAll([]
byte
(name), -
1
))
f.Println(
"mustCompile.FindAllString --------------> "
,
musComp.FindAllString(name, -
1
))
f.Println(
"mustCompile.FindAllSubmatch ------------> "
,
musComp.FindAllSubmatch([]
byte
(name), -
1
))
f.Println(
"mustCompile.FindAllStringSubmatch ------> "
,
musComp.FindAllStringSubmatch(name, -
1
))
f.Println(
"mustCompile.FindIndex ------------------> "
,
musComp.FindIndex([]
byte
(name)))
f.Println(
"mustCompile.FindStringIndex ------------> "
,
musComp.FindStringIndex(name))
f.Println(
"mustCompile.FindSubmatchIndex ----------> "
,
musComp.FindSubmatchIndex([]
byte
(name)))
f.Println(
"mustCompile.FindStringSubmatchIndex ----> "
,
musComp.FindStringSubmatchIndex(name))
f.Println(
"mustCompile.FindAllIndex ---------------> "
,
musComp.FindAllIndex([]
byte
(name), -
1
))
f.Println(
"mustCompile.FindAllStringIndex ---------> "
,
musComp.FindAllStringIndex(name, -
1
))
f.Println(
"mustCompile.FindAllSubmatchIndex -------> "
,
musComp.FindAllSubmatchIndex([]
byte
(name), -
1
))
f.Println(
"mustCompile.FindAllStringSubmatchIndex -> "
,
musComp.FindAllStringSubmatchIndex(name, -
1
))
f.Println(
"\n--------Replace functions--------\n"
)
f.Println(
"mustCompile.ReplaceAll -----------------> "
,
musComp.ReplaceAll([]
byte
(name), []
byte
(
"Bow bow!"
)))
f.Println(
"mustCompile.ReplaceAllStirng -----------> "
,
musComp.ReplaceAllString(name,
"Bow bow!"
))
f.Println(
"mustCompile.ReplaceAllLiteral ----------> "
,
musComp.ReplaceAllLiteral([]
byte
(name), []
byte
(
"T"
)))
f.Println(
"mustCompile.ReplaceAllLiteralString ----> "
,
musComp.ReplaceAllLiteralString(name,
"T"
))
}