I’ve the below code, where I want the user to enter some key words, them find what from these words are exisiting in a given string, but the resulting matches
sliceis an empty slice of a length equal to text to be checked
playground
package main
import (
"fmt"
"regexp"
)
func main() {
p := []string{}
p = append(p, "engineer")
p = append(p, "doctor")
var skills string
for _, z := range p {
skills += `|` + z
}
fmt.Println(skills)
re := regexp.MustCompile(`(?i)` + skills)
matches := re.FindAllString("I'm an engineer not a doctor", -1)
fmt.Println(matches)
for i, j := range matches {
fmt.Println(i, j)
}
}