I mean like this
" T" It's no 3 Character
"T T" It's no 3 Character
" T " It isn.
"TTT" It's true
" TTT" is true
" TT T" is true
how to check that with regex
i'm trying "^[\s]{3,100}$" but it does'nt work
Thanks.
I mean like this
" T" It's no 3 Character
"T T" It's no 3 Character
" T " It isn.
"TTT" It's true
" TTT" is true
" TT T" is true
how to check that with regex
i'm trying "^[\s]{3,100}$" but it does'nt work
Thanks.
I'm assuming you want to test for at least three non-whitespace characters. In which case this pattern should work.
^\s*(\S\s*){3,100}$
[Test]
public void Test()
{
Regex pattern = new Regex(@"^\s*(\S\s*){3,100}$");
Assert.IsFalse(pattern.IsMatch(" T"));
Assert.IsFalse(pattern.IsMatch("T T"));
Assert.IsFalse(pattern.IsMatch(" TT"));
Assert.IsTrue(pattern.IsMatch("TTT"));
Assert.IsTrue(pattern.IsMatch(" TTT"));
}
What isn't clear from your question is if white space is allowed or if the match should fail if any white space is present.
\s* to work with your " TTT" scenario.You can use regex /(\w)\1{2,}/ to match any character, followed by two or more of the same character like this in JavaScript: (you will have to translate to ASP.NET)
a = [" T ", " T", "T ", "TTT", "TTAT"]
for(i=0;i<a.length;i++)
console.log(i, a[i], a[i].match(/(\w)\1{2,}/) != null)