Yury Kaspiarovich
Yury Kaspiarovich

Reputation: 2137

How to determine if string contains arabic symbols?

I need to know, If the string is in Arabic to change the layout of my html page. How do I do this?

Upvotes: 2

Views: 1453

Answers (3)

Fabio
Fabio

Reputation: 19176

With latest ruby (at least 2.0.0 I think) also string =~ /\p{Arabic}/ will work

Upvotes: 5

dirk
dirk

Reputation: 271

You should be able to use a Unicode regular expression (example of Unicode in a Ruby regex) to check for the presence of Unicode Arabic characters.

Upvotes: 1

fl00r
fl00r

Reputation: 83680

You can try this gem https://github.com/peterc/whatlanguage

Upvotes: 0

Related Questions