Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
What if you got input like tHe-caMEL-Case
You can also just add the
i
case insensitive flag to your RegExp. Also, you don't need block parameterx
I wanted this hahahha but couldn't make it. I got stuck on how to reference. tried gsub(/regex/, '\1'.capitalize). no success and no succes when passed as block.
Very nice
@DaltheCow the most important part in that regex,
(.)
, is the parentheses though, which captures the.
("any character except newline") and feeds it into$1
.I assume you mean
[a-zA-Z]
and yes that's required to match upper case letters after the symbols.pretty basic regex so you should probably read up on them and practice (I suggest eloquent javascript chapter 9).
The . means any character except newlines
You can't just switch out the . for [a-z], you have to do [a-z||A-Z]
This comment is hidden because it contains spoiler information about the solution
I used
[a-z]
in mine as you don't want to.upcase
on non-letters.The letter after the underscore/hyphen matched in the regex.
There are brackets around the full stop, those brackets are what you can reference with
$1
and so on.What is
$1
?What is
$1
?The string interpolation is unnecessary. You can just do $1.upcase
Very smart!