Replacing only the first occurrence of a word in a string
<p>I am having some issues with regular expression mainly because I think the information I can find is not specifically for powershell and all the samples I have tried either error or don't work as intended. I am trying to replace the first occurrence of a word in a string with another word but not replace any other occurrences of that word. for an example take the string:</p>

<p><code>My name is Bob, her name is Sara.</code></p>

<p>I would like to replace the first occurrence of <code>name</code> with <code>baby</code> so the resulting string would be </p>

<p><code>My baby is Bob, her name is Sara.</code> </p>

<p>I have been working in <a href="https://regex101.com/" rel="noreferrer">https://regex101.com/</a> to try to build and see what is selected as I go but as I said none of these have a powershell flavor of regex. In that I can just turn off the <code>global</code> flag and it seems to select the first occurrence but not in powershell. So I am really at a loss of where to begin all really have at this point is selecting all occurrences of the word <code>name</code>with:</p>

<pre><code>$test = "My name is Bob, her name is Sara."
$test -replace 'name', 'baby'
</code></pre>