Regex replace help

Richard Shaw hobbes1069 at
Sat Dec 3 23:07:37 UTC 2011

I'm writing my own cmake module for finding TinyXML and I'm trying to
extract the version from the header.

For some reason it's matching the whole file no matter what I do. I've
looked through several of the cmake modules in
/usr/share/cmake/Modules and don't see what I'm doing that's so

The relevant lines in /usr/include/tinyxml.h are:

const int TIXML_MAJOR_VERSION = 2;
const int TIXML_MINOR_VERSION = 6;
const int TIXML_PATCH_VERSION = 1;

To speed up the testing I'm trying to come up with a sed equivalent to
make sure it's returning the version numbers properly.

Here's what I have:
$ echo "const int TIXML_MAJOR_VERSION = 2;" | sed 's/const int
TIXML_MAJOR_VERSION = \([0-9]+\).*/\1/'
const int TIXML_MAJOR_VERSION = 2;

The "echo" is one of the lines I'm trying to match while only
returning the version number. For some reason I'm getting the whole
line back...

Can anyone give me a hint before I pull all my hair out?


More information about the devel mailing list