Click here to Skip to main content
15,917,060 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how can i find a string contains junk character or not ?
Posted
Comments
OriginalGriff 1-Oct-12 7:20am    
Depends on your definition of "junk character".

Your "junk" could be someone else's actual language.

What are you trying to do that you think you need this?
Madhav Hatwalne 1-Oct-12 7:37am    
My junk is other than English alphabets,numbers and special characters present on keyboard
Tejas Vaishnav 1-Oct-12 7:39am    
any example.?
Madhav Hatwalne 1-Oct-12 7:50am    
ÎÒµ±²É¹º¾­ÀíµÄÈý°Ñ»ð

1 solution

What you can probably do is define a regex of allowed characters (or non-allowed characters, depending on your requirement), then check the string against it as shown below

C#
Regex myCheck = new Regex("^[a-zA-Z0-9]*$");
if (myCheck.IsMatch(myString)) 
{
  HandleNonAllowedcharacter();
}


Hope that helps
-Milind
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900