Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does go regexp's any charcter match newline

Tags:

regex

go

Go's re2 syntax document says that the any character (.) matches any character, including newline (s=true). However I wrote a simple program whose result showed that the any character did not match newline at all. The program can be found here:

http://play.golang.org/p/pccP52RvKS

like image 707
mawenbao Avatar asked Nov 24 '13 10:11

mawenbao


1 Answers

Like most other (all?) regex engines, dot does not match newlines unless you add the "dot all" flag (?s) to the regex.

I tested this using your link and it worked.

https://golang.org/pkg/regexp/syntax

like image 69
Bohemian Avatar answered Oct 04 '22 03:10

Bohemian