1
1
12rbah2021-02-11 13:37:19
go
12rbah, 2021-02-11 13:37:19

Differences between regular expressions in go and in grep?

In general, such a problem that grep normally selects expressions from a file, the command looks like this grep '^//' rtf.php, I write such code in go, but it doesn’t find anything.

b,_ := ioutil.ReadFile("rtf.php")
  r,_ := regexp.Compile(`^//`)

I have an assumption that go does not consider that the character after \n starts on a new line, so it does not output anything for such a regular expression. Do I understand correctly that in order to implement such a search, it will be necessary to make a function in which the text will be read line by line and then run through a regular expression (I assume that grep is done something like this)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dodo512, 2021-02-11
@12rbah

Just add a modifier (?m)
`(?m)^//`

T
TANK_IST, 2017-09-11
@TANK_IST

See Selenium .
Or you can write a JS script faster and add it to google chrome using the Tampermonkey plugin .

X
xutegino, 2017-09-11
@xutegino

NightmareJS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question