For better understanding, is there a way to finish the title case code challenge?

Tell us what’s happening:
Referencing past challenges, I didn’t want to use arrays or loops. I thought it needed to be something using expressions ie /\d+/g. I also used the resource link at: Using an inline function that modifies the matched characters,

As a beginner to JavaScript, is there any way that this logic would work or could be completed? I could get the sentence to be either entire caps or lowercase, not how to break the code apart into words or spaces (with w or s). Using match, I had to remove the boolean values, I had no idea I needed the “^”, but was testing it out to get a solution with the training material so far and what I could look up. Thank you!

edit: for clarification and I’m also trying to understand Replace’s RegExp a lot better

Your code so far

  function titleCase(str) {
  function lowerToUpperCase (match, offset, string) {
    return (offset > 0, "" ) + match.toLowerCase();
  //if after a space, capitalize the first letter
        return str.replace(/[A-Z]+/g, lowerToUpperCase);
  //need to change it to only the first letter & drop the boolean value
  //required to turn it into an array to grab the first character??

    //return str.charAt(0).toUpperCase(); Capitalize first character

titleCase("I'm a little tea pot");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:

I solved this challenge using replace and a function. They key is to get the correct regular expression. You really only need the match argument. My solution first converted the entire string to lowercase. Next, my regular expression matched the first character of the string and any situation where a word character followed any character that was not a word character, dash, or apostrophe. This would only match a single character and then my replace callback function would return this letter after it first converted it to uppercase (using toUpperCase).