Hi guys, I have a specific question. How can I capitalize every first letter of words in a string when it’s separated by something else than space ?
For example, if I have this text:
@kernels-main
I would like it become:
@Kernels-Main
Hi guys, I have a specific question. How can I capitalize every first letter of words in a string when it’s separated by something else than space ?
For example, if I have this text:
@kernels-main
I would like it become:
@Kernels-Main
You can split the process by
At least until you need more performance I would start with that.
Something like this works:
"@kernels-main".gsub(/[@-]([^@-]+)/) do |piece|
piece[0] + piece[1..].titleize
end