3

这个问题是一个扩展的问题: How to replace QRegExp in a string?

在那个问题上,问题就解决了。但现在我需要使用 QRegularExpression 而不是 QRegExp。我应该如何转移 Toby Speight 的答案?

4

2 回答 2

2

QRegExp case insensitive search mode is enabled with Qt::CaseInsensitive.

When you use QRegularExpression that is based on PCRE regex engine, you may use QRegularExpression::CaseInsensitiveOption:

The pattern should match against the subject string in a case insensitive way. This option corresponds to the /i modifier in Perl regular expressions.

于 2020-02-22T23:13:55.630 回答
0

在python中,它是:

re = QRegularExpression(pattern, QRegularExpression.CaseInsensitiveOption | QRegularExpression.DotMatchesEverythingOption)

如果您需要 2 个选项

re = QRegularExpression(pattern, QRegularExpression.CaseInsensitiveOption | QRegularExpression.DotMatchesEverythingOption)

于 2022-01-30T21:49:19.753 回答