Regular expression with no maximum limit
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 l开发者_运维问答imit for maximum characters.
.{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.
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
- regular-expressions.info
- Repetition
- The Dot Matches (Almost) Any Character
- Character Classes
Ehm.. Using a regular expression when you just want to check the length of a string? Try something like
inputString.Length >= 15
精彩评论