7 ms·
> In Lua it's only the start/end of the string There's an additional caveat: if you use the optional "init" parameter to specify an offset into the string to s
by denzquix 2y ago
> In Lua it's only the start/end of the string
There's an additional caveat: if you use the optional "init" parameter to specify an offset into the string to start matching, the ^ anchor will match at that offset, which may or may not be what you expect.
- vitiral 2y agoThat is a good point, and something I've actually (personally) used quite a bit when writing parsers
- Dylan16807 2y ago> which may or may not be what you expect I find it hard to imagine any other expectation passing the rubber duck test. "Oh, so you expected the match to always fail, no matter what the string was?"
- denzquix 2y agoWell, it's not a completely outlandish scenario that the value of `init` might come from a variable that is sometimes at the start of the string and sometimes not, and a newcomer might expect `^` to only match when it is. Don't get me wrong, it's certainly far more useful as it is, I'm glad it works this way.