Regex matches any character 5 or more times

I have this regex pattern:

^[.]{5,}$ 

That I want to return true if the tested string has 5 or more characters.

I.E. it will only return false if the string contains 4 or less characters.

Currently it returns true, regardless of the number of characters, and I do not understand why.

+8
regex
source share
3 answers

Do you want to

 ^.{5,}$ 

But actually - just use the built-in string length function in your language of choice

+18
source share

I think you do not need ^ and $. Try simply:

 .{5,} 
+2
source share

Try this regex:

  .{5,} 

more characters to make up the minimum post ...

+2
source share

All Articles