| |
or |
|---|---|
() |
grouping |
^ |
start |
$ |
end |
* |
0 or more |
|---|---|
+ |
1 or more |
? |
0 or 1 |
{min,max} |
between min and max |
[abcde] |
one of those characters |
|---|---|
[a-z] |
a character from a through z |
\d |
digit |
\s |
whitespace |
Write a regular expression (slides) that would match the following kinds of patterns. You can use the site Rubular to test your regex.
/^[ABCDF][+\-]?$/
/^[ABCDF][+\-]|F$//^[ACGT]+$//^\d{5}(-\d{4})?$/ (with optional “+4”)/^\d{4}(-?\d{4}){3}$//^[-]?\d+(\.\d+)?$/
/^[-]?(\d+(\.\d+)?|\.\d+)$//^[-]?\d*(\.\d+)?$/?/^\$[1-9]\d{2,}\.\d{2}$//^[a-z]*[aeiou][a-z]*[aeiou][a-z]*$/i
/^[a-z]*([aeiou][a-z]*[aeiou][a-z]*){2,}$/i/^[qs][^ ]*zz/ (not /^[qs].*zz/)
/[aeiou]{5}/i (why don’t we need {5,}?)
/.{25}/ (why don’t we need {25,}?)
/(\?!){2}$/ (why don’t we need {2,}?)
/^1|5|10|25|50$/ or /^10?|50?|25$/
/^\d{1,3}(\.\d{1,3}){3}$/
/[a-z]+( +[a-z]+){2}/i (why don’t we need {2,}?)
/"[^"]+"/