Jump to content

Can't get group from RegExp


photo

Recommended Posts

Hi, I need to extract a poart in a String, and RegExp should perfectly suited for that.

RegExpPtr reg = RegExp::create();
reg->compile("^[0-9]+:(.*)$");

String test = "12:foobar";
reg->match(test); // returns 1, so it does match!
reg->getNumGroups(); // returns 0, should return 1!
reg->getGroup(0); // returns "", should return "foobar"

What am I doing wrong?

(regexp tested OK on https://regex101.com/ )

Link to comment
×
×
  • Create New...