Regex replace help

Miloslav Trmač mitr at volny.cz
Sun Dec 4 02:00:00 UTC 2011


On Sun, Dec 4, 2011 at 12:07 AM, Richard Shaw <hobbes1069 at gmail.com> wrote:
> $ echo "const int TIXML_MAJOR_VERSION = 2;" | sed 's/const int
> TIXML_MAJOR_VERSION = \([0-9]+\).*/\1/'
> const int TIXML_MAJOR_VERSION = 2;

By replacing (sed 's/../../') with (sed -n 's/../../p') you can see
that the regex doesn't match.  The cause is that sed recognizes an
"\+" operator, not "+" operator.
   Mirek


More information about the devel mailing list