I am developing a web application using PHP 5.3.x. Everything is working fine, but unable to solve an issue due to regular expression problem with Bengali Punctuation. Following is my code:
$value = 'u09ACu09BEu0982u09B2u09BEu09A6u09C7u09B6'; $value = mb_convert_encoding($value, 'UTF-8', 'UTF-16BE'); //$value = 'বাংলাদেশ'; //$value = 'Bangladesh'; $pattern = '/^[p{Bengali}]{0,100}$/'; //$pattern = '/^[p{Latin}]{0,45}$/'; echo preg_match($pattern, $value);
Whether I pass Bengali word or not, it always returns false
. In JavaEE application I used this Regular Expression
p{InBengali}
But in PHP it not working! Anyways how do I solve this problem?
Advertisement
Answer
Maybe this will help you:
The PHP preg functions, which are based on PCRE, support Unicode when the /u option is appended to the regular expression.
From regex in Unicode