Feature #4099
Enhancement: add support for wildcards to the field calculator
| 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: |
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 almost 2 years ago
- Status changed from New to Closed
regexp_replace added in 6c26773f9bd689bfe3002c4cdb349301419a8daa
You can do regexp_replace(Descrip,'^.*\\(', '') now. See also QString::replace
Updated by Alister Hood almost 2 years ago
Great!
Updated by Alister Hood almost 2 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.