I noticed that Feedzirra uses this regex to get the ETag from response header:
/.*ETag:\s(.*)\r/
Personally I would have written this one:
/ETag:\s(.*)\n/
Here the questions:
- Why does it put .* at the beginning even if it is unnecessary (\A is not specified)?
- Why does it use \r instead of \n? What is the difference?
"\r\n"as a line ending. In most programming languages, only"\n"is treated as a line ending. The\rmakes sure that the \r is not swallowed inside the.*which would give erroneous whitespace at the end of the capture.