How to check that string contains is english only
i have a string which contains values like:
string str ="Abhigyan Prakash,Primeshow,NewsPoint,NCP,Inflation,सरकार,राहुल,प्राइम शो,न्यूजप्वाइंट,कमजोर,एनसीपी,अभिज्ञान प्रकाश,Rahul";
i have used below code to convert it to array list:
ArrayList altags = new ArrayList( str.Split(','));
now i wants to remove all those strings from arraylist which belongs from non-english language (in my context those words which are written in "hin开发者_开发技巧di" should be removed)
please suggest me how to check that string is written in english (with numeric and symbols) or in other language..
NOTE: i have no issue with generic list. i cant take it also. but please tell me how to check that string contains only alphabets + numeric + symbols Thanks
If you need to filter strings with latin symbols, numeric symbols and spaces, you may use regular expressions.
var regex = new Regex("[a-zA-Z0-9 ]*");
var result = str.Split(',')
.Where(s => regex.Match(s).Value == s)
.ToArray();
According to the ascii tables characters of English words (with numeric) should fall between the ranges 48 - 57 (0-9), 65-90 (A-Z) and 97-122 (a-z)
You might want to add to the ranges punctuation signs and other imported characters like é (from fiancé for example).
精彩评论