This question already has answers here:
Regular expression doesn't work in Go

(2个答案)


9个月前关闭。




我正在尝试将某些正则表达式从ECMAScript样式转换为Golang样式,这里是:
((r|🇷)+)(( |\n)*)((🇪|e)+)(( |\n)*)((p|🇵)+)(( |\n)*)((🇴|o)+)(( |\n)*)((🇸|s)+)(( |\n)*)((t|🇹)+)

基本上,关键是匹配“r🇪p O s t”之类的消息。
我试图用“\ s”代替“”,但仍然无法正常工作。有什么想法吗?

最佳答案

这对你有用吗?

[r🇷]\s*[🇪e]\s*[p🇵]\s*[🇴o]\s*[🇸s]\s*[t🇹]

带不区分大小写的标志

Demo & explanation

关于regex - 将正则表达式从JS风格转换为Golang风格? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59469348/

10-10 17:02