Feature request #4099
Enhancement: add support for wildcards to the field calculator
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | - | ||
Pull Request or Patch supplied: | No | Resolution: | |
Easy fix?: | No | Copied to github as #: | 14081 |
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
#1 Updated by Jürgen Fischer over 13 years ago
- Status changed from Open to Closed
regexp_replace
added in 6c26773f9bd689bfe3002c4cdb349301419a8daa
You can do regexp_replace(Descrip,'^.*\\\\(', '')
now. See also QString::replace
#2 Updated by Alister Hood over 13 years ago
Great!
#3 Updated by Alister Hood over 13 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.