I have data set which holds, for instance, this syntax format: brand_shoetype_color (nike_270_red). I want to know how to (1) replace the underscore (_) with a gap (" ") and (2) capitalize each word in the new array.
Desire answers: Nike 270 Red.
I have data set which holds, for instance, this syntax format: brand_shoetype_color (nike_270_red). I want to know how to (1) replace the underscore (_) with a gap (" ") and (2) capitalize each word in the new array.
Desire answers: Nike 270 Red.
2
Answers
Here is a one liner just for fun:
{{ 'nike_270_red' | replace: '_', '_zzzz_' | camelcase | replace: 'Zzzz', ' ' }}
Where this
_zzzz_
is just a placeholder that I remove afterwards withZzzz
.For reference I will probably not use it in a project but hey the more options the better.