Any way to escape a Go string in a regular expression?

后端 未结 1 461
北荒
北荒 2020-12-29 20:46

I\'m wanting to match ^(@|\\s)*{{string}}:? whereas {{string}} is dynamically defined. It may have periods and dashes and any number of things in it and I reall

相关标签:
1条回答
  • 2020-12-29 21:30

    regexp.QuoteMeta does the deed.

    0 讨论(0)
提交回复
热议问题