Regex Pal

Dan's Tools

Kansas License Numbers

Provide a written description that explains the pattern developed and the process/methodology behind the design. This type of regular expression is unique and can be difficult because there were other states that had a similar regular expression pattern as Kansas. So what I did initially was look at the the license formats provided on the website for Kansas. I noticed that it could be formatted in 3 different ways. So I wrote an expression for each one: 1. 1Alpha+1Numeric+1Alpha+1Numeric+1Alpha=[A-Z]\d[A-Z]\d[A-Z] 2. 1Alpha+8Numeric=[A-Z]\d{8} 3. 9Numeric= \d{9} In order to get all 3 regular expressions to fit, I had to use the | character to divide each one. Like I said previously I noticed that other states used a similar format so after I created each regular expression, I added the literal word “Kansas” in front so the regular expression would also have to include this to search properly. If on the servers the wording was different, you could adjust the regular expressions to fit accordingly. I feel that this is sufficient to find the appropriate data, however I am always willing to learn from others about how I can improve of this concept since I am new to it.


Top Regular Expressions

Cheat Sheet

Character classes
. any character except newline
\w \d \s word, digit, whitespace
\W \D \S not word, digit, whitespace
[abc] any of a, b, or c
[^abc] not a, b, or c
[a-g] character between a & g
^abc$ start / end of the string
\b word boundary
Escaped characters
\. \* \\ escaped special characters
\t \n \r tab, linefeed, carriage return
\u00A9 unicode escaped ©
Groups & Lookaround
(abc) capture group
\1 backreference to group #1
(?:abc) non-capturing group
(?=abc) positive lookahead
(?!abc) negative lookahead
Quantifiers & Alternation
a* a+ a? 0 or more, 1 or more, 0 or 1
a{5} a{2,} exactly five, two or more
a{1,3} between one & three
a+? a{2,}? match as few as possible
ab|cd match ab or cd