Skip to content

Instantly share code, notes, and snippets.

@sageworksstudio
Last active February 15, 2018 19:28
Show Gist options
  • Select an option

  • Save sageworksstudio/86cd0e8d3d5209b86427e47400a76ed7 to your computer and use it in GitHub Desktop.

Select an option

Save sageworksstudio/86cd0e8d3d5209b86427e47400a76ed7 to your computer and use it in GitHub Desktop.
Regex cheat sheet

Regex cheat sheet

Search for an alpha-string between two delimiters.

Example: 'images/0-31604-01079-9_label_small.jpg'

In this case we're looking for the string 'label' between the underscore delimiters (not including the delimiters).

This would be our regex /(?<=_)+[A-Za-z]+(?=_)/

  1. Look for the preceeding delimiter, underscore (?<=_)
  2. Plus +
  3. All alpha characters upper and lower case [A-Za-z]
  4. Plus +
  5. Look for the ending delimiter, underscore (?=_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment