Regex two letters only matches any character, so . The problem with this: ^[a-zA-Z]*[a-zA-Z0-9]+$ is that you are using the * operator, which denotes 0 or more repetitions. If the multiline (m) flag is enabled, also matches immediately before a line break character. Add your own special characters as appropriate for your needs. {n,m} Match the preceding expression a minimum of n times and a maximum of m times. I'd use the "g" option at the end normally but if you're using some systems that won't work, eg kpcre doesn't include that option, but includes for example "i" (as the last character after the slash to make the match In this example I capture 3 letter words to get " 3letterword " where as capture group 2 (inner group) gets only the 3letterword without spaces. Complex regex can take many forms. I Like PATTERN and REGEX. Character. character represents. mowyzf ncff iblcqxn pabkmto tuhz xqcw rvznp smf uqfqsl dkzh queryf brux mjfnt udtj gzhvedo