Skip to content

Instantly share code, notes, and snippets.

@bsodmike
Last active Mar 9, 2021
Embed
What would you like to do?
Solutions to Lessons @ RegexOne.com

Lesson 3 - http://regex101.com/r/bZ6eC3

Objective:

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

Solutions:

([cmf]+[an]+)[^d]
([cmf]+[an]{2})[^d]

Lesson 4 - http://regex101.com/r/kZ5gG1

Objective:

match   hog
match   dog
skip    bog

Solutions:

([d-o]+)[^bg]

Lesson 5 - http://regex101.com/r/aR9vJ9

Objective:

match Ana
match Bob
match CpC
skip  aax
skip  bby
skip  ccz

Solutions:

([A-Ca-p]+)[^a-cx-z]

Lesson 6 - http://regex101.com/r/lT4hV9

Objective:

match   wazzzzup
match   wazzzup
skip    wazup

Solutions:

([wa]+[z]{3,4}[up]+)

Lesson 7 - http://regex101.com/r/yD9bL7

Objective:

match   aaaabcc
match   aabbbbc
match   aacc

Solutions:

(a+b*c+)

Lesson 8 - http://regex101.com/r/vW6eJ2

Objective:

match   1 file found?
match   2 files found?
match   x files found?

Solutions:

([\d\w+]\s[file?s]+\sfound\?)

Lesson 9 - http://regex101.com/r/yZ4qG2

Objective:

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

Solutions:

([\d\.]+\s+[a-c]+)          # matches any whitespace
([\d\.]+[" "|\t]+[a-c]+)    # specifically matches spaces and tab-based whitespace

Lession 10 - http://regex101.com/r/oH4iG7

Objective:

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

Solutions:

^([a-zA-z]+\:\s?successful)$

Lession 11 - http://regex101.com/r/hZ7kE1

Objective:

match   file_a_record_file.pdf
match   file_yesterday.pdf
skip    testfile_fake.pdf.tmp    

Solutions:

([a-z+\_?]+)\.pdf$
([a-z+\_?]+)(?=\.pdf$)      # using positive lookahead

Lesson 12 - http://regex101.com/r/jM9vV5

Objective:

match   Jan 1987    capture     Jan 1987, 1987
match   May 1969    capture     May 1969, 1969
match   Aug 2011    capture     Aug 2011, 2011

Solutions:

^([a-zA-z]+\s+([\d]+))$
@arifams
Copy link

arifams commented Mar 25, 2016

Thanks man. I was stuck and luckily found this gem, cool :)
Lesson 12 i tried with ^(.*([0-9]{4}))$ and it works somehow (well I was quite surprised)

Loading

@lifesucx
Copy link

lifesucx commented Apr 9, 2019

For lesson 11 the bottom solution works, but instead of an underscore it should be 0-9

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment