PDA

View Full Version : Problem with QRegExp/C++



rte
4th September 2009, 22:56
Hello,
I found here an example with boost regular expression ( http://shootout.alioth.debian.org/u32q/benchmark.php?test=regexdna&lang=gpp&id=3 )

Perl example: http://shootout.alioth.debian.org/u32q/benchmark.php?test=regexdna&lang=perl&box=1
Python example: http://shootout.alioth.debian.org/u32q/benchmark.php?test=regexdna&lang=python&box=1

Input file ( http://shootout.alioth.debian.org/download/regexdna-input.txt ) and output file ( http://shootout.alioth.debian.org/download/regexdna-output.txt )

I am new in Qt and C++ and very interesting how it would be looks like with QRegExp and is it possible to do write it shorter?

Best reagards,

wysota
4th September 2009, 23:40
QRegExp supports the perl syntax of regular expressions so the expression will be similar.

rte
5th September 2009, 00:02
Thank you for the link.

Is it possible to use Qt e.g. QTextStream to simplify this program ( http://shootout.alioth.debian.org/u32q/benchmark.php?test=regexdna&lang=gpp&id=3 ), because it is very long.

wysota
5th September 2009, 00:16
Is it possible to use Qt e.g. QTextStream to simplify this program ( http://shootout.alioth.debian.org/u32q/benchmark.php?test=regexdna&lang=gpp&id=3 ), because it is very long.

You don't have to implement the rope, that's for sure. You can open the QTextStream on a string or a byte array but you can use the string or byte array directly too. QTextStream won't give you any benefit here.

BTW. The thread title is still undescriptive. You don't really have a problem with QRegExp. You just need help with "Converting a regexp program from Perl or Python to Qt/C++" or something like that. Although I'm not sure what your actual problem is. Is it a school assignment? Or are you trying to prove some point (and what point?) to someone?

rte
5th September 2009, 03:53
This is not a school assignment I only find this example in internet. I am looking a way to rewrite this code in oder to get it shorter, because in Python or Perl is it possible to solve this problem in only few lines. I would like to learn how is the best and shortest way to work with files similar to Python and Perl.

wysota
5th September 2009, 08:52
I don't think this problem is oriented on working with files, it's about regular expressions. For file access see QFile.