Ruby RegEx search and replace
Posted on 2008-10-10
This should be simple:
text = 'adam|paul|mike'
I want to replace that with -> <b>adam</b><b>paul</b><b>mike</b>
So each name seperated by a | OR a name at the end of the string should be enclosed in <b> tags. Here's what I have so far:
But this leaves off the last name. I'd also like to replace [a-z]* with just .* - (which for some reason is way off)
As a bonus, is there a way to also get the values inside the <b> tags to drop the | - but that can always easily be done in a second step