I’m looking for a safe way of building a string of a HTML element id from another element id.
I need to go from something like “attr_name_442_a” to “attr-row-422”, the text part of the ids are consistent with just the number changing. This number will be in the range of 1 to 4 digits.
I thought of doing this but is there a better Ruby style method?
newID = oldID.gsub("_","-").gsub("name","row").gsub("-a","")
You may be able to pull this off with a single Regex