Validating last character regex
Notice that the whitespace characters are just like any other character and the special metacharacters like the star and the plus can be used as well.
Here it is: Assert position at a word boundary «\b» Match the regular expression below and capture its match into backreference number 1 «([A-Z][a-z][- ]|[A-Z][- \'][A-Z][a-z][- ]|[a-z][ -\'][A-Z][a-z])» Between 2 and 5 times, as many times as possible, giving back as needed (greedy) «» Note: I repeated the capturing group itself. Put a capturing group around the repeated group to capture all iterations.
"[\w.-] [a-z0-9]" // Consists of alphanums only and ends with a letter or digit "$", // End of a string "i"); // Make the pattern case-insensitive var str = 'azzz-zzzzzzz_AZ0.9'; document.write(str ": " re.test(str) ""); str = '.azzzzzzz-A_Z09'; document.write(str ": " re.test(str)); When you can, use consecutive tokens that are mutually exclusive in order to create contrast. )$)" // Must contain 3-15 alphanums (NOTE: only works if [-._] cannot follow one another) "[a-z0-9] " // Cannot start with ., _ or -, starts only with letter or digit "(?
:[^a-z0-9]*[a-z0-9])[^a-z0-9]*$)" // Must contain 3-15 alphanums "(?! .*[._-][._-])" // Cannot contain consecutive .-, -_, .., --, etc.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?