I am trying to capitalize words with a format like this:
america [asia] europe
and I want to make it look like this:
America [Asia] Europe
What regex should I put in the .split option?
I am trying to capitalize words with a format like this:
america [asia] europe
and I want to make it look like this:
America [Asia] Europe
What regex should I put in the .split option?
If your string is america [asia] europe
, then there is no need for regex
. Instead use, the builtin helpers methods within Rails. The method titleize
is meant for this kind of thing.
➜ test_app git:(master) ✗ rails c
Loading development environment (Rails 4.2.0)
test_app :001 > t = 'america [asia] europe'
=> "america [asia] europe"
test_app :002 > t.titleize
=> "America [Asia] Europe"