Feature request #4099

Enhancement: add support for wildcards to the field calculator

Added by Alister Hood over 3 years ago. Updated over 3 years ago.

Status:Closed Start Date:07/19/2011
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:-
Target version:-
Platform: Resolution:
Platform version: Patch supplied:No
Status info: Tag:

Description

It would be very useful to be able to do things like this:
replace(Descript,'%(','')

Or maybe that should be this (I don't understand why SQL has LIKE instead of allowing the use of wildcards with an "="):
replace(Descript,LIKE'%(','')

History

Updated by J├╝rgen Fischer over 3 years ago

  • Status changed from Open to Closed

regexp_replace added in 6c26773f9bd689bfe3002c4cdb349301419a8daa

You can do regexp_replace(Descrip,'^.*\\(', '') now. See also QString::replace

Updated by Alister Hood over 3 years ago

Great!

Updated by Alister Hood over 3 years ago

Thoughts for my future reference:

Wildcards can be used instead of full regular expressions, by adding the second line here:
QRegExp re( value2.string() );
re.setPatternSyntax(QRegExp::WildcardUnix);

or:
QRegExp re( value2.string() );
re.setPatternSyntax(QRegExp::Wildcard);

WildcardUnix suffers from https://bugreports.qt.nokia.com//browse/QTBUG-10192,
which I think is why (if there was a function using it called wildcard_replace) you would need to do wildcard_replace(Descrip,'\\**','') rather than wildcard_replace(Descrip,'\\*','')

Using WildcardUnix I thought that you should be able to do wildcard_replace(Descrip,'\\\\','') if you need to replace a literal \, but it doesn't seem to work.

- Many users would be scared of regular expressions
- I imagine most of the time the desired results could be achieved using wildcards rather than full regular expressions, and it would be simpler and faster.

Also available in: Atom PDF