| [reply] |
| [reply] |
In general, if I need to use a regex that involves anything like:
- unicode characters (whether literal or via "\x{HHHH}" notation)
- unicode character classes (\pL \pM \pP \p{InArabic} etc)
- procedural manipulation in a regex string replacement (s/.../.../e)
- "symbolic" classes that I only learned through perl usage (\w, \d, \s)
- non-capturing groups: (?:...)
- zero-width assertions, including:
- look-ahead and look-behind assertions
- ...
my inclination is to just use Perl. I wouldn't be surprised if other tools implement some or all of the same things (possibly with the same syntax that Perl uses), but I know Perl does all these things, so it's just less work to use Perl.
(Also, I know that Perl regexes in 5.10 and later allow a lot of stuff that I haven't even needed to learn yet...) | [reply] [d/l] |
This is not the comprehensive answer you are looking for, but, IMO, Perl has better and more exhaustive capabilities than the old unix utilities. On the other hand, grep has the -P switch which allows Perl regex syntax to be used.
| [reply] [d/l] |
Comparison of various regexp syntax: Regexp Syntax Summary
Learn about Perl regexp: perlrequick, perlretut, perlre
vim: I began learning about regular expressions from using Vim's regexp, and I can attest to its flexibility + features. When you say vi, you're most likely using vim in vi-compatible mode - so don't limit yourself and do enable Vim's full features (with :set nocp). Vim allows you to visually learn about regexp matching with highlighted search:
:set hlsearch
:set incsearch
sed: You can replace sed commands with perl. You're better off in the long run learning Perl, IMHO.
grep: Beyond simple regexp, there's ack - use Perl regular expressions! | [reply] [d/l] [select] |