May 15, 2012

AcerExtensa AcerExtensa
Robot Herder
570 posts

[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!

 Signature 

God is Real unless explicitly declared as Integer.

2 replies

May 27, 2012

Volker Volker
Robot Herder
5428 posts

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

May 29, 2012

AcerExtensa AcerExtensa
Robot Herder
570 posts

have done this without regexp.

  1. long chk_version(QString ver)
  2. {
  3.     return ver.contains(' ')?ver.left(ver.indexOf(' ')).remove('.').toLong():ver.remove('.').toLong();
  4. }

 Signature 

God is Real unless explicitly declared as Integer.

 
  ‹‹ Suggestion for new QFileSystemWatcher.      QTree model architecture ››

You must log in to post a reply. Not a member yet? Register here!