B
booksnore
I am writing some code to search for strings that contain every letter
of the alphabet. At the moment I am using the method below to check to
see if a string contains every letter of the alphabet. I wanted to use a
regular expression but I could not find an ‘AND’ operator within the
regular expression – so I need something like match true if string
contains ‘a’ and ‘b’ and ‘c’ and ‘d’ ..etc,etc. If anyone has any
thoughts on how I can provide the check more effectively than I am doing
at the moment the help would be very much appreciated.
private static bool InAlphabet(string text)
{
if(text==null)
{
return false;
}
int count = 97;
bool IsValid = true;
while (IsValid && count < 123)
{
// Cast character from integral type
string regexStr = "(" + (char)count + ")";
Regex regex_x = new Regex(regexStr);
Match m_x = regex_x.Match(text);
IsValid = m_x.Success;
count++;
}
return IsValid;
}
of the alphabet. At the moment I am using the method below to check to
see if a string contains every letter of the alphabet. I wanted to use a
regular expression but I could not find an ‘AND’ operator within the
regular expression – so I need something like match true if string
contains ‘a’ and ‘b’ and ‘c’ and ‘d’ ..etc,etc. If anyone has any
thoughts on how I can provide the check more effectively than I am doing
at the moment the help would be very much appreciated.
private static bool InAlphabet(string text)
{
if(text==null)
{
return false;
}
int count = 97;
bool IsValid = true;
while (IsValid && count < 123)
{
// Cast character from integral type
string regexStr = "(" + (char)count + ")";
Regex regex_x = new Regex(regexStr);
Match m_x = regex_x.Match(text);
IsValid = m_x.Success;
count++;
}
return IsValid;
}