QString str = "sdf com df ru"; qDebug() = str.indexOf("(com|ru)"); Returns -1; Did by Max Schlee, what is wrong?
QString str = "sdf com df ru"; qDebug() = str.indexOf("(com|ru)"); Returns -1; Did by Max Schlee, what is wrong?
Try changing the code a bit and it will work:
QString str = "sdf com df ru"; qDebug() << str.indexOf(QRegExp("(com|ru)")); Most likely, your code is trying to strictly search for the substring "(com | ru)" in the text and does not perceive it as a regular expression, because in fact you are passing the string to the indexOf method, not the regular expression.
Source: https://ru.stackoverflow.com/questions/604310/
All Articles