-1

I'm looking for a function to test if a given string contains only (thanks @meagar) characters in given language. The sample string is UTF-8; the additional argument can be anything (I imagine it however working with locale strings). It shouldn't return true for any non-alphabetic characters.

As such the output of such function should be:

test("jérôme", "FR_fr") = true
test("jérôme", "PL_pl") = false
test("jrme", "FR_fr") = true
test("jrme", "PL_pl") = true
test("***hi***", "PL_pl") = false

I'm looking for a generic function - as: it should work for any valid locales, be it: FR_fr, PL_pl, GD_ie or ZH_cn.

Any ideas?

edit: valid point by @deceze - let's change this from [language] to [alphabet]

4

1 回答 1

1

您可以使用Unicode“脚本”属性(假设您的正则表达式引擎支持它)将匹配限制为特定脚本。但是,您无法获得比这更具体的信息。

于 2013-06-04T20:02:45.263 回答