Skip to content

Instantly share code, notes, and snippets.

@hosiawak
Created December 2, 2010 13:18
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 hosiawak/725276 to your computer and use it in GitHub Desktop.
Save hosiawak/725276 to your computer and use it in GitHub Desktop.
a = 'class="one"'
b = 'class="one two"'
c = '"other string"'
d = 'class="one two three"' # four five, any number of classes
e = 'id="one"'
Create a regular expression (r) in Ruby to achieve the following
a.r -> 'class="one_1"'
b.r -> 'class="one_1 two_1"'
c.r -> '"other string"'
d.r -> 'class="one_1 two_1 three_1"'
e.r -> 'id="one_1"'
etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment