查询-不区分大小写和重音 [英] Query - Case and accent insensitive

查看:92
本文介绍了查询-不区分大小写和重音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to perform a regex query with cloudant and can't figure out how to do a case and accent insensitive query.

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

I've tried the following (for case insensitive): ^.*((?i)<needle>).*$ but it doesn't work.

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

For the accents (french), I don't even know how to start...

推荐答案

要执行不区分大小写的查询,只需在调用caseless 选项-3 rel = nofollow> re:run / 3 或 re:compile / 2 ,例如:

To do a case insensitive query just add the caseless option when invoking re:run/3 or re:compile/2, e.g.:

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

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

I am not sure if accent insensitive queries are supported, but you can try to specify alternative letters using [], e.g.:

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

如果那还不够,那么您可能需要检查 Erlang中的Unicode支持特别是 re 中的,以查看您是否想要支持实现。

If that's not enough then you may need to check the Unicode support in Erlang and in re in particular to see if what you want to achieve is supported.

这篇关于查询-不区分大小写和重音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆