Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] Need help with regular expression



  • Hello everybody!
    Can somebody please help me with regular expression for QRegExp? I just hate them :(

    I need to get from strings simple numeric strings:
    7.5.5468 dev -> 755468
    7.5.5468 pre -> 755468
    7.6 -> 76
    7.6 pre -> 76
    7.7 beta1 -> 77 (without 1 on the end)

    Thank you in advance!



  • Do you mind posting your solution here, so that others could benefit from it too? Thanks!



  • have done this without regexp.

    @
    long chk_version(QString ver)
    {
    return ver.contains(' ')?ver.left(ver.indexOf(' ')).remove('.').toLong():ver.remove('.').toLong();
    }
    @


Log in to reply