Tyler
Tyler

Reputation: 4709

issues matching number in string with boost regex

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!!

Upvotes: 0

Views: 901

Answers (1)

Alex Jasmin
Alex Jasmin

Reputation: 39496

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.

Upvotes: 2

Related Questions