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

Nathan Woodrow madmanwoo at gmail.com
Fri Sep 23 20:27:45 PDT 2016


Hey,

When would you normally need an escape char for LIKE?

- Nathan

On Fri, Sep 23, 2016 at 6:33 PM, René-Luc Dhont <rldhont at gmail.com> wrote:

> 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
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160924/3234fad0/attachment.html>


More information about the Qgis-developer mailing list