Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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