-5

When I try to make this pattern in c++ the compiler gives me a runtime error

regex IntegerWSign("^((-)|(\+))[0-9]{1,}$");
Barmar
  • 741,623
  • 53
  • 500
  • 612
momo_hoho
  • 1
  • 1

1 Answers1

0

\+ is the valid notation in a regular expression, but inside a C++ string that needs to be \\+.

Your expression was being interpreted as:

^((-)|(+))[0-9]{1,}$

Where that's not valid.

tadman
  • 208,517
  • 23
  • 234
  • 262