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

René-Luc Dhont rldhont at gmail.com
Wed Sep 28 01:14:49 PDT 2016


Hi devs,

I have opened a PR https://github.com/qgis/QGIS/pull/3535
Reviews are welcome

Le 24/09/2016 à 05:27, Nathan Woodrow a écrit :
> 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 
> <mailto: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 <mailto:Qgis-developer at lists.osgeo.org>
>     List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <http://lists.osgeo.org/mailman/listinfo/qgis-developer>
>     Unsubscribe:
>     http://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <http://lists.osgeo.org/mailman/listinfo/qgis-developer>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160928/9e348bf8/attachment-0001.html>


More information about the Qgis-developer mailing list