Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active December 25, 2015 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/7058293 to your computer and use it in GitHub Desktop.
Save havenwood/7058293 to your computer and use it in GitHub Desktop.
str = "aaa [first_name] bar [first_name] [last_name]"
last = str.scan(/\[last_name\]/).size
first = str.scan(/\[first_name\]/).size
remaining = str.gsub(/\[(first_name|last_name)\]/, '').size
first * 15 + last * 10 + remaining
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment