1

Very simply, here is test code which fails.

QRegExp BASIC_FORMAT ("^\\s*(.+?)\\s*,\\s*(.+)\\s*$");
QString test = "Catherine the Great, Szczecin 2/5/1729 to Saint Petersburg 17/11/1796";

qDebug ("%i", BASIC_FORMAT .indexIn (test));

This prints -1, although if I copy the strings into something like regex101.com (resolving double-backslashes myself, of course) then it matches as expected.

Why is QRegExp not matching in this case?

demonplus
  • 5,613
  • 12
  • 49
  • 68
spraff
  • 32,570
  • 22
  • 121
  • 229

1 Answers1

2

QRegExp does not support non-greedy quantifiers like +?

You could use [^,]+ instead

BeniBela
  • 16,412
  • 4
  • 45
  • 52