dongxie3352 2015-07-30 11:20
浏览 24
已采纳

搜索“إ”字符并返回包含“ا”或“أ”或“إ”char的所有单词? [关闭]

In Arabic language there are some character the public people can may way for example character ا can be written by one of these (أ,إ,ا) and character ه can be written by one of these (ه, ة) and so on.

for more clarify: may user search the keyword ايمان I will return all results like ايمان or أيمان or إيمان, and if he search for إيمان I will return also the same three words, and if he search for أيمان I will return also the same three words.

I want if user search of one of them (أ,إ,ا) return all words which contain any one of them

  • 写回答

3条回答 默认 最新

  • dougaicha5258 2015-07-30 13:35
    关注

    I found the answer:

    first I replace all similar chars to one char in search keyword by php like this:

    $keyword = str_replace('أ', 'ا', $keyword);
        $keyword = str_replace('إ', 'ا', $keyword);
        $keyword = str_replace('ى', 'ي', $keyword);
        $keyword = str_replace('ة', 'ه', $keyword);
    

    then I replace column value stored in database in where sentence like this:

    ->whereRaw(" (REPLACE(REPLACE(REPLACE(REPLACE(page_title_ar, 'ة', 'ه'), 'أ', 'ا'), 'إ', 'ا'), 'ى', 'ي') like '%" . $keyword . "%' OR "
        . "REPLACE(REPLACE(REPLACE(REPLACE(page_summery_ar, 'ة', 'ه'), 'أ', 'ا'), 'إ', 'ا'), 'ى', 'ي') like '%" . $keyword . "%' OR "
        . "REPLACE(REPLACE(REPLACE(REPLACE(page_content_ar, 'ة', 'ه'), 'أ', 'ا'), 'إ', 'ا'), 'ى', 'ي') like '%" . $keyword . "%' OR "
        . "REPLACE(REPLACE(REPLACE(REPLACE(page_title_en, 'ة', 'ه'), 'أ', 'ا'), 'إ', 'ا'), 'ى', 'ي') like '%" . $keyword . "%' OR "
        . "REPLACE(REPLACE(REPLACE(REPLACE(page_summery_en, 'ة', 'ه'), 'أ', 'ا'), 'إ', 'ا'), 'ى', 'ي') like '%" . $keyword . "%' OR "
        . "REPLACE(REPLACE(REPLACE(REPLACE(page_content_en, 'ة', 'ه'), 'أ', 'ا'), 'إ', 'ا'), 'ى', 'ي') like '%" . $keyword . "%'"
        . " ) and deleted <> 1")
    

    and the problem

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?