搜索卡扎菲的正则表达式 [英] Regular expression to search for Gadaffi

查看:40
本文介绍了搜索卡扎菲的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试搜索 Gadaffi 这个词,它可以拼写成许多不同的 方式.搜索此内容的最佳正则表达式是什么?

这是一个包含 30 个变体的列表:

<前>加扎菲卡扎菲加达菲卡扎菲卡扎菲卡扎菲卡扎菲加萨菲加达菲加扎菲加扎菲加达菲格达菲卡达菲卡达菲卡扎菲卡扎菲卡扎菲卡达菲卡达菲卡扎菲卡扎菲卡扎菲卡扎菲卡扎菲卡扎菲卡塔菲夸萨菲库扎菲卡达菲

我目前最好的尝试是:

\b[KG]h?add?af?fi$\b

但我似乎仍然缺少一些变体.有什么建议吗?

解决方案

\b[KGQ]h?add?h?af?fi\b

阿拉伯语转录是(维基说)Qaḏḏāfī",所以可能添加一个 Q.和一个 H(卡扎菲",正如文章(见下文)提到的).

顺便说一句,为什么在正则表达式的末尾有一个 $?


顺便说一句,关于这个主题的好文章:

卡扎菲、卡扎菲或卡扎菲?为什么利比亚领导人的名字有这么多不同的拼写方式?.


编辑

要匹配文章中的所有姓名,您'稍后提到,这应该与它们全部匹配.让我们只是希望它不会匹配很多其他东西:D

\b(Kh?|Gh?|Qu?)[aeu](d['dt]?|t|zz|dhd)h?aff?[iy]\b

I'm trying to search for the word Gadaffi, which can be spelled in many different ways. What's the best regular expression to search for this?

This is a list of 30 variants:

Gadaffi
Gadafi
Gadafy
Gaddafi
Gaddafy
Gaddhafi
Gadhafi
Gathafi
Ghadaffi
Ghadafi
Ghaddafi
Ghaddafy
Gheddafi
Kadaffi
Kadafi
Kaddafi
Kadhafi
Kazzafi
Khadaffy
Khadafy
Khaddafi
Qadafi
Qaddafi
Qadhafi
Qadhdhafi
Qadthafi
Qathafi
Quathafi
Qudhafi
Kad'afi

My best attempt so far is:

\b[KG]h?add?af?fi$\b

But I still seem to be missing some variants. Any suggestions?

解决方案

\b[KGQ]h?add?h?af?fi\b

Arabic transcription is (Wiki says) "Qaḏḏāfī", so maybe adding a Q. And one H ("Gadhafi", as the article (see below) mentions).

Btw, why is there a $ at the end of the regex?


Btw, nice article on the topic:

Gaddafi, Kadafi, or Qaddafi? Why is the Libyan leader’s name spelled so many different ways?.


EDIT

To match all the names in the article you've mentioned later, this should match them all. Let's just hope it won't match a lot of other stuff :D

\b(Kh?|Gh?|Qu?)[aeu](d['dt]?|t|zz|dhd)h?aff?[iy]\b

这篇关于搜索卡扎菲的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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