PDA

View Full Version : Non-greedy (lazy) RegExp in QtScript



ultr
26th May 2010, 01:05
Qt's QRegExp does not support the "?" modifier for the quantifiers (http://doc.qt.nokia.com/4.6/qregexp.html#notes-for-perl-users), and neither RegExp from QtScript does.

However in Qt/C++ one can use QRegExp::setMinimal() to make the quantifiers non-greedy.

But how to do it in QtScript?

wysota
26th May 2010, 09:37
Ask yourself (or your favourite search engine) how to do it in JavaScript.

http://www.regular-expressions.info/javascript.html

ultr
26th May 2010, 12:47
The link you provided does not say a word about the problem.

In JavaScript the only way I'm aware of is using the ? modifier.
There is no global modifier for the entire regexp, like "i" for case insensitiveness.
And there seems to be no RegExp object's method which allows this.

So since Qt does not support the ? modifier, it should enable other way of making the QtScript's RegExp non-greedy.

wysota
26th May 2010, 13:03
The link you provided does not say a word about the problem.
It says the problem is outside the scope of this forum.


In JavaScript the only way I'm aware of is using the ? modifier.
Then why don't you use it?


So since Qt does not support the ? modifier, it should enable other way of making the QtScript's RegExp non-greedy.
Qt Script is an implementation of ECMAScript (aka JavaScript), not a full blown separately maintained product. You can always export QRegExp to your script if you want it available there.

ultr
26th May 2010, 13:19
In JavaScript the only way I'm aware of is using the ? modifier.
Then why don't you use it?
Simply because it does not work in QtScript.


I will try exporting QRegExp. I hope it won't requite more exports, since these scripts are meant to be an easy interface for users. They should be able to use it just like JavaScript without reading tons of additional documentation.

wysota
26th May 2010, 16:40
Simply because it does not work in QtScript.
How exactly did you try it?


I will try exporting QRegExp. I hope it won't requite more exports, since these scripts are meant to be an easy interface for users. They should be able to use it just like JavaScript without reading tons of additional documentation.
You can export any function you want in a way you see fit. It will not require anything unless you make it require something.