suggest change

C++ provides only 4 anchors:

Let’s say for example we want to capture a number with it’s sign:

auto input = "+1--12*123/+1234"s;
smatch sm;

if(regex_search(input, sm, regex{ "(?:^|\\b\\W)([+-]?\\d+)" })) {

    do {
        cout << sm[1] << endl;
        input = sm.suffix().str();
    } while(regex_search(input, sm, regex{ "(?:^\\W|\\b\\W)([+-]?\\d+)" }));

Live Example

An important note here is that the anchor does not consume any characters.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents