Based on new details, try another expression:
(?i)^(?=[a-z])(?=.*[0-9])([a-z0-9!@#$%\^&*()_?+\-=]){8,15}$
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I need help with this RegEx please.
I want to have a strong password with the following:
Kindly help..
Thanks,
Jassim
Based on new details, try another expression:
(?i)^(?=[a-z])(?=.*[0-9])([a-z0-9!@#$%\^&*()_?+\-=]){8,15}$
Check this expression:
^(?=.{8,15}$)(?=\p{L})(?=.*\p{N}.*$).*
If it does not work, or "special character" means something specific, then show the code and sample passwords.
Hello @Viorel ,
Oops! Sorry, Mea culpa, I got the order of the input and pattern arguments wrong.
This is a bit off-topic but possibly still relevant for @Jassim Al Rahma to create a bullet-proof regular expression.
I am now having difficulty identifying a definitive source of information for this topic. The .NET documentation says:
The following table lists the character escapes supported by regular expressions in .NET.
CHARACTER ESCAPES IN .NET
Character or sequence Description
All characters except for the following:. $ ^ { [ ( | ) * + ? \ Characters other than those listed in the Character or sequence column have no special meaning in regular expressions; they match themselves.
The characters included in the Character or sequence column are special regular expression language elements. To match them in a regular expression, they must be escaped or included in a positive character group. For example, the regular expression \$\d+ or [$]\d+ matches "$1200".
Wikipedia says (in the "POSIX basic and extended" section):
A bracket expression. Matches a single character that is contained within the brackets. For example, [abc] matches "a", "b", or "c". [a-z] specifies a range which matches any lowercase letter from "a" to "z". These forms can be mixed: [abcx-z] matches "a", "b", "c", "x", "y", or "z", as does [a-cx-z].
The - character is treated as a literal character if it is the last or the first (after the ^, if present) character within the brackets: [abc-], [-abc]. Note that backslash escapes are not allowed. The ] character can be included in a bracket expression if it is the first (after the ^) character: []abc].
Gary
P.S.
I also just found this: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05
A bracket expression (an expression enclosed in square brackets, "[]" ) is an RE that shall match a specific set of single characters, and may match a specific set of multi-character collating elements, based on the non-empty set of list expressions contained in the bracket expression.
The following rules and definitions apply to bracket expressions:
A bracket expression is either a matching list expression or a non-matching list expression. It consists of one or more expressions: ordinary characters, collating elements, collating symbols, equivalence classes, character classes, or range expressions. The <right-square-bracket> ( ']' ) shall lose its special meaning and represent itself in a bracket expression if it occurs first in the list (after an initial <circumflex> ( '^' ), if any). Otherwise, it shall terminate the bracket expression, unless it appears in a collating symbol (such as "[.].]" ) or is the ending <right-square-bracket> for a collating symbol, equivalence class, or character class. The special characters '.', '*', '[', and '\' ( <period>, <asterisk>, <left-square-bracket>, and <backslash>, respectively) shall lose their special meaning within a bracket expression.