views:

21

answers:

1

I'm trying to determine whether or not a string contains a number. This doesn't seem to be working.

static const regex re("([0-9]+)");
cout << regex_match("L5", re);

prints

0

Thanks!!

+2  A: 

From the boost docs on regex_match:

Note that the result is true only if the expression matches the whole of the input sequence. If you want to search for an expression somewhere within the sequence then use regex_search.

Alexandre Jasmin
gah. I knew it was something really fundamental that I was missing. Thanks.
Tyler