in reply to Re^3: hackerrank.com question
in thread hackerrank.com question

But that code actually works. It returns the expected results, including the terminal email address. It just doesn't on hackerrank.com. It did when I changed [^\w\.] to (?:$|[^\w\.]), which is what the regex site needed.

If it's not a Perl version thing, then it's likely some kind of emulator issue on their part, or perhaps the regex web site is wrong in not matching it. It seems to me that EOD is not a word, personally.

Replies are listed 'Best First'.
Re^5: hackerrank.com question
by writch (Sexton) on Sep 27, 2018 at 16:02 UTC
    Per what choroba said (perhaps privately) regarding the source document, I did a hexdump of the source document, and found that vi was appending, but not presenting, a newline in that data set.

    If I explicitly added a newline, there were two terminal newline characters in hexdump.

    Mystery solved, sort of, but that looks like a bug in vim. I always trusted it before.
      Not a bug, but a 'feature'. Apparently, vim automatically appends every line with CR/LF characters per whatever file mode is set. The suggested path to fixing this is to use the ':set binary' command in conjunction with ':%!xxd' and ':%!xxd -r' to remove this extra character.
        Other than that, the way to resolve this is to use echo -n '<stuff>' > filename.

        That gives results like pasting with no explicit newline at the end used to in vi, and it's much less work.