'Case insensitive search mode with QRegularExpression

This question is an expanded question of this : How to replace QRegExp in a string?

In that question, problem is solved. But now I need to use QRegularExpression instead of QRegExp. How should I transfer the answer of Toby Speight?



Solution 1:[1]

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.

Solution 2:[2]

In python, it's:

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

And if you need 2 options

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wiktor Stribiżew
Solution 2 buddemat