O
O
Ord EO2019-07-12 16:44:16
ruby
Ord EO, 2019-07-12 16:44:16

How to make downcase only for first letters in ruby?

How to write a function in ruby ​​that will make only the first letters in a sentence small.
Example:
Hello Everybody I Am Adam McCartney
Result
hello everybody i am adam mcCartney

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stockholm Syndrome, 2019-07-12
@OrdeO

"Hello Everybody I Am Adam McCartney".gsub(/(^| )(\w)/) { $1 + $2.downcase }

0
0xD34F, 2019-07-12
@0xD34F

str.gsub(/\b\w/){|m| m.downcase}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question