[Qgis-developer] Expression: does an escape char is defined for LIKE expression

René-Luc Dhont rldhont at gmail.com
Fri Sep 23 01:33:47 PDT 2016


Hi Devs,

I'd like to know if an escape character is defined for the LIKE operator 
in QGIS Expression.

If I take a look at the code src/core/qgsexpression.cpp:4343 no escape 
char is used
```
         if ( mOp == boLike || mOp == boILike || mOp == boNotLike || mOp 
== boNotILike ) // change from LIKE syntax to regexp
         {
           QString esc_regexp = QRegExp::escape( regexp );
           // XXX escape % and _  ???
           esc_regexp.replace( '%', ".*" );
           esc_regexp.replace( '_', '.' );
           matches = QRegExp( esc_regexp, mOp == boLike || mOp == 
boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
         }
```
Do you think we have to add one ?

Regards,
René-Luc


More information about the Qgis-developer mailing list