Most RegExp implementations nowadays allow "\K" to reset the match and continue from a certain point - essentially a way to allow lookbehinds that aren't fixed length. However, using this seems to always cause queries to fail (and they don't if I remove the \K), so I have to assume it's not implemented! I'd like to see the RegExp implementation updated to allow these types of newfangled sequences. After all, one support article suggests to look at Rubular for support with RegExp, and Rubular supports \K!
Here's an example use case for \K:
Let's say I have some data in the form "Text::More Text::Even More Text::Etc" and I want to grab "MoreText" from this. But I also want to ensure that I can still grab it if my data is presented as just "Text::MoreText", so I can't solve this with a find function! How do I do this? Well, ideally, with an attribute that looks like this:
\K resets the match, so I can still specify that it starts with "^[\w\s]+(?:::)", but then match "[\w\s]+" afterward.
Now, I'm not the strongest at RegExp, so there may be other workarounds to this problem, but it sure would be nice to have an updated implementation to allow us to handle situations this easily!
Vous devez vous connecter pour laisser un commentaire.