EnexoOnoma
EnexoOnoma

Reputation: 8836

Regex to match greek characters?

I constructed the following regex

preg_match_all('#(autom(.*?)tic|(.*?)anual)#', $str2b, $gears);

but I want to change it to match greek characters. I would like to match the words βενζίνη and πετρέλαιο but I don't get it to work.

preg_match_all('#(βενζί(.*?)η|πετρέλ(.*?)ιο)#', $str2b, $gears);

How can I do this?

Upvotes: 0

Views: 1929

Answers (1)

anubhava
anubhava

Reputation: 785226

You should use /u regex switch for unicode matching:

preg_match_all('#(βενζί(.?)η|πετρέλ(.?)ιο)#u', $str2b, $gears);

btw you can use \p{Greek} property for matching Greek letters.

Upvotes: 5

Related Questions