我需要从golang中的多行字符串中获取一行,该字符串具有常见的单词,如如果该单词是enabled,则我需要从多行字符串中获取该行一旦启用,则我们将继续。。字符串是他们的服务器有问题。我必须继续执行任务。希望服务器将为每个人启用。一旦启用,则我们将继续。。我正在尝试此golang代码
package main
import (
"fmt"
"regexp"
)
func main() {
s := "Their have a problem with the server.I have to continue the task.Hope the server will enable for everyone.Once enable then we will continue."
val := "enabled"
re := regexp.MustCompile(`[^.]*(?i)` + val + `[^.]*[\.| ]`)
fmt.Println(re.FindAllString(s, -1))
return
}
1条答案
按热度按时间k0pti3hp1#
我不是很明白你的问题,但试试这个:
如果您的字符串是多行字符串,则应首先按“\n”拆分。