使用 QRegularExpression 提取完整的句子

Extract a complete sentence using a QRegularExpression

我目前正在尝试提取以下句子:

This is a rectangle. Its height is 193, its width is 193 and the word number is 12.

来自以下行:

ID: 1 x: 1232 y: 2208 w: 193 h: 390 wn: 12 ln: 13 c: This is a rectangle. Its height is 193, its width is 193 and the word number is 12 !

我必须使用 QRegularExpressions 来做到这一点。因此,我的代码如下:

regularExpression.setPattern("[c:](?:\s*)$");
QRegularExpressionMatch match = regularExpression.match("ID: 2 x: 845 y: 1633 w: 422 h: 491 wn: 78 ln: 12 c: qsdfgh");
if (match.hasMatch()) {
    QString id = match.captured(0);
    qDebug()<<"The annotation is:"<<id;
    return id;
}
return 0;

然而,它根本不起作用,我不明白为什么(也许我的正则表达式不正确)。我几天来一直被这个问题困住了。

你能帮帮我吗?

使用以下正则表达式解析 c: 之后的所有内容,并从字符串的开头删除可能的白色 space:

regularExpression.setPattern("c:\s*(.*$)");