Title Case a Sentence Challenge: Help with regex

Can you explain why this regex (see below) doesn’t find the “i” at the start of the sentence?
My understanding of this regex is it looks for any alphanumeric that is found at the beginning of the string OR that follows a whitespace however the result from console.log is :

[ '', ' a', ' L', ' t', ' p' ]

which ignores the “i” at the start of the string ):


function titleCase(str) {
    let regex = /^|\s\w/g;
    console.log(str.match(regex));
    return true
}

titleCase("i'm a LITTLE tea pot");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0.

Challenge: Title Case a Sentence

Link to the challenge:

Thanks all !

it seems you can’t use the ^ with an OR
why not try with “letter at the beginning OR letter preceeded by a space”? you can group characters together surrounding them with parenthesis