Skip to content

Instantly share code, notes, and snippets.

@davidbella
Created October 30, 2013 18:22
Show Gist options
  • Save davidbella/7237461 to your computer and use it in GitHub Desktop.
Save davidbella/7237461 to your computer and use it in GitHub Desktop.
Regex: Matches _lower_camel_case words for ActiveRecord migrations
http://regex101.com/r/mV8rA7
/(?:_([^_.]+))+?/g
01_create_cats.rb
02_create_all_the_dogs.rb
/(?:_([^_.]+))+?/g
(?:_([^_.]+)) Non-capturing Group 1 to infinite times [lazy]
_ Literal _
1st Capturing group ([^_.]+)
Negated char class [^_.] 1 to infinite times [greedy] matches any character except:
_. One of the following characters _.
g modifier: global. All matches (don't return on first match)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment