This is probably the best multi-word solution.
I totally forgot about \b, it is excellent.
I totally emulated it with /(?:^|\s)\w/, since capitalizing the whitespace doesn't do anything, but this is just so much better!
Does the i flag improve performance and not harm it though?
I'd potentially hoist the regex and callback constructions out of the function, although that may be crazy to do.
If you only want the first word capitalized:
This is probably the best multi-word solution.
I totally forgot about
\b
, it is excellent.I totally emulated it with
/(?:^|\s)\w/
, since capitalizing the whitespace doesn't do anything, but this is just so much better!Does the
i
flag improve performance and not harm it though?I'd potentially hoist the regex and callback constructions out of the function, although that may be crazy to do.
Hi, the
i
doesn't does anything in this case, it is my mania of writing it always. The mdn's docu says this about \w:So \w is case insesitive already.
OH NO
:'(
That was expected, which result do you wanted?
Try my honestly unironically inferior regex and see:
regex ahhhh π I need to get better at that cause I know how powerful it is π