I would like to capture second occurence of the text replaced by a star in the following string:
SW * <br>
ie string starting with SW
ending with <br>
in a QString, using the RegEx with Qt.
an example here: the string is
SW = min(1, max(0, pow(10, -0.2 - 6.5 ) ** (1.0 / 0.2)))<br>
and expected result is
= min(1, max(0, pow(10, -0.2 - 6.5 ) ** (1.0 / 0.2)))
So far, i have QRegExp rx("^[\ SW](.*)[<br>]$");
which is not compiling.
How would you do ?
The compilation issue is probably due to trying to escape the ampersand (\&
). But other than that, your regex is mostly right, just overusing character groups ([]
), they are not for grouping. This expression works in my tests: SW(.*)<br>
, so in your case you'd do something like
QRegExp rx(" SW(.*)<br>")