Part of the problem is that I have a web application that builds forms
dynamically. I then allow for validation routines for the given controls.
For validation the system allows for multiple regular expressions for each
control if needed and the form. When someone posts their data I loop through
all of the controls and then pull their specific validation requirements from
the database.
Let me know if you know what the regular expression would be to limit X
number of characters in a string.
Thanks
Karl said:
Todd,
I'm almost positive you'll be better off going ToCharArray() and looping
through the char array....something like:
public static bool HasTooManyOfASingleCharacter(string source, char
character, int max) {
char[] array = source.ToCharArray();
int count = 0;
for (int i = 0; i < array.Length; ++i ){
char c = array
;
if (c == character){
++count;
if (count > max){
return true;
}
}
}
return false;
}
--
MY ASP.Net tutorials
http://www.openmymind.net/
I am in need of a regular expression that tests and fails if there are 14
or
more of a character in the test string. There can be up to 13 of these
characters in the string and any other characters, but at the 14th of this
character it should fail.
Thanks,
Todd Meister