I Need a regular expression which accepts all types of characters (alphabets, numbers and all special characters), and miniumum number of characters should be 15 and no limit for maximum characters.
+4
A:
.{15,}
Assuming that you use settings where the dot matches all characters. It's really hard to be any more specific unless you mention which platform you're using.
Matti Virkkunen
2010-06-05 15:08:05
Hm, I guess the OP meant anything else then whitespace if I read it right, could be /^[^\s]{15,}/, which is pretty portable I think (there will always be exceptions though, so you're right to ask).
Wrikken
2010-06-05 15:11:02
I am using asp.net.
KhanS
2010-06-05 15:11:53
+3
A:
The basic repetition options for regex are as follows:
x?
matches zero or onex
x*
matches zero or morex
x+
matches one or morex
x{3}
matches exactly 3x
x{3,}
matches at least 3x
x{3,5}
matches at least 3 and at most 5x
To match absolutely any character, you use .
in single-line mode. To enable single-line mode, consult documentation for your specific language. In Java, this is (?s)/Pattern.DOTALL
.
If by "all types of characters" you really mean everything but whitespace, then there's a special character class for that: \S
(with a capital S
). The pattern you're looking for is therefore:
\S{15,}
References
polygenelubricants
2010-06-05 15:13:54
+1
A:
Ehm.. Using a regular expression when you just want to check the length of a string? Try something like
inputString.Length >= 15
simendsjo
2010-06-05 16:28:16