Regular Expression

From GLMWiki
Revision as of 15:44, 25 August 2016 by Laury (Talk | contribs)

Jump to: navigation, search

RegEx can be tricky! Hopefully this will provide some help.

This is an example of perl-regex format which is used in Netbeans and Atom

a-c(\d[{2-2}]\d{1}?[{0-9}]\d)

This will match a-c213 as well as a-c2199. It will not match b2199 nor a-c229. Can you figure out why?

The ? makes the following statement optional.

\d is a digit

[{x-y}] indicates a range from x to y. This can be alphanumeric.

{1} indicates that just that character is accepted.

Everything outside the parentheses is literal. So "a-c" matches that string, literally.