7 ms·
Ask HN: Tools for working with Vim regex?
I have been trying to convert fairly complex-for-me PCRE/JavaScript style regular expressions[1] to be Vim-compatible.
I have not been able to find any tool that will automatically convert to and from Vim regex. Is there one I have missed?
In addition, the main Regex testing apps I use (regexr.com and regex101.com) don't support Vim regex, which makes figuring out what's wrong more tedious.
The closest I have gotten is by asking Phind to do it (https://www.phind.com/search?cache=43967e8e-ec1c-4e9a-94ab-5049857e330f), but it does not produce a working result on its own.
The only real resource I've found is https://vimregex.com/.
Is there any automated tool that could help with this task?
Thanks!
[1]: This common-OCR-error-correcting regex is one of them: (?<!\b[A-Z][a-z]{3}|th|whil|i)(?:e|s)((?:\s|(?:\n){2})(?:"|*)?[A-Z]) (Edit: HN is removing some of the escape characters. See: https://gist.githubusercontent.com/curiositry/dad4379d7c6de3e5969e367f0a69aa4e/raw/49521de5694c3e839a63ca482574e0654c909ec6/regex.txt)
- gregjor 4y agohttps://chrisarcand.com/perl-compatible-regular-expressions-in-vim/ https://chrisarcand.com/perl-compatible-regular-expressions-... https://vim.fandom.com/wiki/Perl_compatible_regular_expressions https://vim.fandom.com/wiki/Perl_compatible_regular_expressi...
- deleted 4y ago[deleted]
- Curiositry 4y agoThanks for your reply! I had tried using :perldo, and thought it hadn't worked (I was distracted by the "Variable length lookbehind is experimental in regex" warning, and didn’t notice that it had in fact run silently). However, in this case I expect there to be false positives, and need to run it interactively; perldo it replaces globally without confirmation. Is there any way to get match-highlighting & confirmation with perldo?
- gregjor 4y agoI don't how to get the interactive substituting or match highlighting with :perldo, but you can diff the result with the saved version to check what got changed: :w! diff % - Or use "git diff" instead of "diff" for nicer output.