35 ms·
Same here; when I saw the title I was like "well obviously not, where did you hear that?" In nearly two decades of using regex I think this might be the first
by Izkata 3y ago
Same here; when I saw the title I was like "well obviously not, where did you hear that?"
In nearly two decades of using regex I think this might be the first time I've heard of $ being end of string. It's always been end of line for me.
- deleted 3y ago[deleted]
- frame_ranger 3y agoYou couldn’t write a post like this if you didn’t start with a strawman.
- dbdudbdiddjc 3y agoIt’s not a straw man, it’s accurate in many contexts.
- michaelt 3y agoTake a look at, for example, these stackoverflow answers about a regex to validate and e-mail address: https://stackoverflow.com/a/8829363 https://stackoverflow.com/a/8829363 These people are I think not intending to say a newline character is permitted at the end of an e-mail address. (Of course people using 'grep' would have different expectations for obvious reasons)
- Izkata 3y agoEven disregarding whether or not end-of-string is also an end-of-line or not (see all the other comments below), $ doesn't match the newline, similar to zero-width matches like \b, so the newline wouldn't be included in the matched text either way. I think this series of comments might be clearest: https://news.ycombinator.com/item?id=39764385 https://news.ycombinator.com/item?id=39764385
- LK5ZJwMwgBbHuVI 3y agoProblem is, plenty of software doesn't actually look at the match but rather just validates that there was a match (and then continues to use the input to that match).