0

I need to build a regular expression to match the following set of strings :

test, tested, testing

And I have the following test scenario :

QRegularExpression re("^[test]{1}[ing|ed]{0,1}", QRegularExpression::CaseInsensitiveOption);

QString test = "test";
QVERIFY(re.match(test).hasMatch() == true );

QString test1 = "tested";
QVERIFY(re.match(test1).hasMatch() == true );

QString test2 = "testing";
QVERIFY(re.match(test2).hasMatch() == true );

QString test3 = "teste";
QVERIFY(re.match(test3).hasMatch() == false );

test3 is failed and I understand the reason, but how can I fix it? I need to skip 'e' character from matching...

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Dmitry
  • 1,912
  • 2
  • 18
  • 29

0 Answers0