Skip to content

Instantly share code, notes, and snippets.

@mort3za
Created June 1, 2018 15:55
Show Gist options
  • Save mort3za/b2765342677e63ba7f4c3462477e5c6d to your computer and use it in GitHub Desktop.
Save mort3za/b2765342677e63ba7f4c3462477e5c6d to your computer and use it in GitHub Desktop.
Brief notes of regex (regular expression)

Regular expression brief notes

Greedy vs lazy evaluation

/<div>.+</div>/
This will not match <div>text</div> because .+ consumes </div> characters. .+ uses greedy evaluation.
/<div>.+?</div> This will match <div>text</div> because .+? uses lazy evaluation and returns control to next expression as it finds first match.

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