如何检查php变量是否包含印地文文本

时间:2016-06-29 15:26:02

标签: php variables hindi

喜欢

$a = चौधरी;
$a = abdul;

如何检查是否有印地文或英文?

1 个答案:

答案 0 :(得分:1)

您可以使用简单的正则表达式检查英文字符:

<?php
$regex = '~^[a-zA-Z]+$~';
$string = 'abdul';
if (preg_match($regex, $string)) {
    echo "All English!";
} else {
    echo "Anything else";
}

您也可以使用\p{xx}的内容,其中xx

之一
  

阿拉伯语,亚美尼亚语,Avestan,巴厘岛语,Bamum,Bassa_Vah,Batak,   孟加拉,          Bopomofo,Brahmi,Braille,Buginese,Buhid,Canadian_Aboriginal,Car-          伊恩,高加索人 - 阿尔巴尼亚人,Chakma,Cham,Cherokee,Common,Coptic,Cunei-          形式,塞浦路斯人,西里尔人,Deseret,梵文,Duployan,Egyptian_Hiero-          字形,爱尔巴桑,Ethiopic,格鲁吉亚,Glagolitic,哥特式,格兰莎,          希腊语,古吉拉特语,Gurmukhi,汉语,韩语,Hanunoo,希伯来语,平假名,          Imperial_Aramaic,Inherited,Inscriptional_Pahlavi,Inscrip-          tional_Parthian,Javanese,Kaithi,Kannada,Katakana,Kayah_Li,          Kharoshthi,Khmer,Khojki,Khudawadi,Lao,Latin,Lepcha,Limbu,Lin-          ear_A,Linear_B,Lisu,Lycian,Lydian,Mahajani,Malayalam,Mandaic,          Manichaean,Meetei_Mayek,Mende_Kikakui,Meroitic_Cursive,          Meroitic_Hieroglyphs,Miao,Modi,Mongolian,Mro,Myanmar,Nabataean,          New_Tai_Lue,Nko,Ogham,Ol_Chiki,Old_Italic,Old_North_Arabian,          Old_Permic,Old_Persian,Old_South_Arabian,Old_Turkic,Oriya,Osmanya,          Pahawh_Hmong,Palmyrene,Pau_Cin_Hau,Phags_Pa,Phoenician,          Psalter_Pahlavi,Rejang,Runic,Samaritan,Saurashtra,Sharada,Sha-          vian,Siddham,Sinhala,Sora_Sompeng,Sundanese,Syloti_Nagri,Syriac,          他加禄语,Tagbanwa,Tai_Le,Tai_Tham,Tai_Viet,Takri,泰米尔语,泰卢固语,          Thaana,Thai,Tibetan,Tifinagh,Tirhuta,Ugaritic,Vai,Warang_Citi,          易。

有关详细信息,请参阅pcre.org