3 ms·
Having never heard of this, it just looks like a list of regex patterns. Am I missing something? There's lots of lists of patterns available [1] If I came acro
by gregmac 4y ago
Having never heard of this, it just looks like a list of regex patterns. Am I missing something? There's lots of lists of patterns available [1]
If I came across this in code, I still have similar issues to regex. I have to question the source and what unit testing exists, that the tests cover the particular cases we care about, and if composed it needs tests anyway.
For context, I always split my regexs to a function and add unit tests for them, and ask the same in PRs. It is one of the easiest tests to write and most beneficial: if I don't discover a case I missed while I come up with example inputs, it protects any future modifications by future devs. It also empowers devs that don't know regexs well to be able to modify them (because they know it won't break) and to approve a PR with one.
I don't see how grok patterns avoid the need for tests (especially if composed), and if there are tests anyway, they're just a level of indirection.
In the worst case, when there's inevitably a bug (or app-specific missing situation) in one of these, it's harder to fix than just having a regex directly.
[1] https://github.com/mmkjony/awesome-regex-1 https://github.com/mmkjony/awesome-regex-1 , https://regexlib.com/DisplayPatterns.aspx?cattabindex=5&categoryId=6 https://regexlib.com/DisplayPatterns.aspx?cattabindex=5&cate...
- mekster 4y agoYou're not missing anything but why reinvent a known regex pattern on every project or even on every instance of its usage in a project when the pattern can be defined to be used by anyone that never changes? In your case, putting the grok patterns in your regex specific function seems to make it more readable.