PDA

View Full Version : Define a QRegExp containing arithmetic operators



aaditya190
4th December 2013, 06:12
Is there a way to define a QRegExp containing all arithmetic operators in a single expression? I am able to do it individually , like for operator + as QRegExp rx("\\+");.. I want to define a single regular expression containing all arithmetic operators. Is it possible? Can anyone help me with this?

ChrisW67
4th December 2013, 11:38
It may be possible but you will have to define "all arithmetic operators". The operators for FORTRAN are different from those for COBOL or Java. You might use a character class and/or alternation.

Rather than starting a new thread for every single regular expression you want to create (1, 2, 3) I suggest your find yourself a good book (http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=regular+expressions) or online tutorial (http://lmgtfy.com/?q=regular+expression+tutorial) on the topic and learn how regular expressions work. The QRegExp docs are not devoid of merit either. There are plenty of tools out there to help your experiment with regular expressions without coding.