Live data from Hacker News

Regex character "$" doesn't mean "end-of-string"

sethmlarson.dev

381–382 of 382 posts

Re: Regex character "$" doesn't mean "end-of-string"

#381
post #63

Isn't a string with a newline character automatically multiline? The new line is just empty but not the first line anymore.

No, it is not. 3.195 Incomplete Line A sequence of one or more non- characters at the end of the file. 3.206 Line A sequence of zero or more non- characters plus a terminating character. courtesy of [0]. See also [1] for rationale on "text file": Text File [...] The definition of "text file" has caused controversy. The only difference between text and binary files is that text files have lines of less than {LINE_MAX}…

Applications that write "incomplete lines"

- VSCODE

- Visual Studio

- Notepad

C/C++ compilers that process "incomplete lines"

   All of them.
Will my users consider it a bug if my program doesn't process "incomplete lines":

    Yes. (Yes, I have had this bug logged 
    against code that I wrote).
Will I consider it a bug if your program doesn't process "incomplete lines":

    Yes.

Re: Regex character "$" doesn't mean "end-of-string"

#382

Earlier quoted context omitted.

No, it is not. 3.195 Incomplete Line A sequence of one or more non- characters at the end of the file. 3.206 Line A sequence of zero or more non- characters plus a terminating character. courtesy of [0]. See also [1] for rationale on "text file": Text File [...] The definition of "text file" has caused controversy. The only difference between text and binary files is that text files have lines of less than {LINE_MAX}…

Applications that write "incomplete lines" - VSCODE - Visual Studio - Notepad C/C++ compilers that process "incomplete lines" All of them. Will my users consider it a bug if my program doesn't process "incomplete lines": Yes. (Yes, I have had this bug logged against code that I wrote). Will I consider it a bug if your program doesn't process "incomplete lines": Yes.

> Applications that write "incomplete lines"

Note that all of those three apps come from the Windows world where CRLF was indeed a line separator, and a file ending with CRLF was considered to have an empty line at the end.

But yes, you absolutely should accommodate for incomplete lines.

Post reply on HN