How to check whether a specified character exists in a string ?
-
Dear All, PLease let me know how to check whether a specified character exists in a text or ? I am validating Password and I want to make sure that the password must contain atleast one numeric(0 to 9) , one special character and one uppercase letter. thanx in advance
-
Dear All, PLease let me know how to check whether a specified character exists in a text or ? I am validating Password and I want to make sure that the password must contain atleast one numeric(0 to 9) , one special character and one uppercase letter. thanx in advance
-
Dear All, PLease let me know how to check whether a specified character exists in a text or ? I am validating Password and I want to make sure that the password must contain atleast one numeric(0 to 9) , one special character and one uppercase letter. thanx in advance
While abc.Contains("0"); ... abc.Contains("%"); May work it will be too slow.
if(abc.Length > MIN_LENGTH){
char c;
for(int i=0;i<abc.length;i++){
c = abc[i];
if(!numberFound)
numberFound = Char.IsNumber(c);
if(!specialFound)
specialFound = Char.IsSymbol(c);
if(!upperFound)
upperFound = Char.IsUpper(c);
if(!lowerFound)
lowerFound = Char.IsLower(c);
if(numberFound && specialFound && upperFound && lowerFound){
valid = true;
break;
}}
}//end if
File Not Found
-
Dear All, PLease let me know how to check whether a specified character exists in a text or ? I am validating Password and I want to make sure that the password must contain atleast one numeric(0 to 9) , one special character and one uppercase letter. thanx in advance
use substring to pull out each character in turn and if the character is of a type set a flag so you know you've found it. at the end all flags should be set and you're ready to go. BTW you should also test for lowercase as you are assuming that Upper case is different from the norm. Russ -- modified at 10:01 Friday 30th March, 2007
-
Dear All, PLease let me know how to check whether a specified character exists in a text or ? I am validating Password and I want to make sure that the password must contain atleast one numeric(0 to 9) , one special character and one uppercase letter. thanx in advance
Hi, String.IndexOfAny(char[]) can check for the presence of any of a collection of chars. and String.ToCharArray() may be useful too. :)
Luc Pattyn [My Articles]