【问题标题】:Query - Case and accent insensitive查询 - 不区分大小写和重音
【发布时间】:2016-02-22 05:45:15
【问题描述】:

我正在尝试使用 cloudant 执行正则表达式查询,但不知道如何执行不区分大小写和重音的查询。

我尝试了以下方法(不区分大小写):^.*((?i)<needle>).*$ 但它不起作用。

对于口音(法语),我什至不知道如何开始......

【问题讨论】:

    标签: regex erlang cloudant


    【解决方案1】:

    要进行不区分大小写的查询,只需在调用re:run/3re:compile/2 时添加caseless 选项,例如:

    18> re:run(<<"abCd">>, <<"c">>, [caseless]).
    {match,[{2,1}]}
    

    我不确定是否支持不区分重音的查询,但您可以尝试使用[] 指定替代字母,例如:

    12> re:run(<<"abęxo"/utf8>>, <<"[eę]"/utf8>>).
    {match,[{2,1}]}
    13> re:run(<<"abexo"/utf8>>, <<"[eę]"/utf8>>).
    {match,[{2,1}]}
    

    如果这还不够,那么您可能需要检查 Unicode support in Erlangin re in particular 以查看是否支持您想要实现的目标。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-10
      • 2018-08-19
      相关资源
      最近更新 更多