is it possible to specify non-capturing groups in sed?
if so, how?
The answer, is that as of writing, you can't - sed does not support it. Sed supports BRE, and ERE, but not PCRE.
(Note- One answer points out that BRE is also known as POSIX sed, and ERE is is a GNU extension via sed -r. Point remains that PCRE is not supported by sed. )
Perl will work, for windows or linux
There is a program albeit for Windows, which can do search and replace on the command line, and does support PCRE. It's called rxrepl. It's not sed of course, but it does search and replace with PCRE support.
C:\blah\rxrepl>echo abc | rxrepl -s "(a)(b)(c)" -r "\1" a C:\blah\rxrepl>echo abc | rxrepl -s "(a)(b)(c)" -r "\3" c C:\blah\rxrepl>echo abc | rxrepl -s "(a)(b)(?:c)" -r "\3" Invalid match group requested. C:\blah\rxrepl>echo abc | rxrepl -s "(a)(?:b)(c)" -r "\2" c C:\blah\rxrepl>
The author(not me), mentioned his program in an answer over here http://superuser.com/questions/339118/regex-replace-from-command-line
It has a really good syntax.
The standard thing to use would be perl.