Skip to content

Instantly share code, notes, and snippets.

@vasuadari
Last active January 8, 2019 10:38
Show Gist options
  • Save vasuadari/ec2b943ac4bc4ee5b54bc96e9fd8f7e7 to your computer and use it in GitHub Desktop.
Save vasuadari/ec2b943ac4bc4ee5b54bc96e9fd8f7e7 to your computer and use it in GitHub Desktop.
Regex 101

Letters

match   abcdefg
match   abcde
match   abc

The 123s

match   abc123xyz
match   define "123"
match   var g = 123;

The Dot

match   cat.
match   896.
match   ?=+.
skip    abc1

Matching specific characters

match   can
match   man
match   fan
skip    dan
skip    ran
skip    pan

Excluding specific characters

match   hog
match   dog
skip    bog

Character ranges

match   Ana
match   Bob
match   Cpc
skip    aax
skip    bby
skip    ccz

Catching some zzz's

match   wazzzzzup
match   wazzzup
skip    wazup

Mr. Kleene Star, Mr. Kleene Plus

match   aaaabcc
match   aabbbbc
match   aacc
skip    a

Characters optional

match   1 file found?
match   2 files found?
match   24 files found?
skip    No files found.

All this whitespace

match   1.   abc
match   2.  abc
match   3.           abc
skip    4.abc

Starting and ending

match   Mission: successful
skip    Last Mission: unsuccessful
skip    Next Mission: successful upon capture of target

Match groups

capture   file_record_transcript.pdf  file_record_transcript
capture   file_07241999.pdf   file_07241999
skip      testfile_fake.pdf.tmp

Nested groups

capture   Jan 1987  Jan 1987 1987
capture   May 1969  May 1969 1969
capture   Aug 2011  Aug 2011 2011

More group work

capture   1280x720  1280 720
capture   1920x1600   1920 1600
capture   1024x768  1024 768

It's all conditional

match   I love cats
match   I love dogs
skip    I love logs
skip    I love cogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment