'Nim regex to perform once not global replace

How do we ask Nim regex to perform once not global replacing it with a specific string (e.g. let sided by Perl syntax) ?

import std/nre

var o="foo bar blah !"
    
echo o.replace( re"(\w+)", "masked")

it'd be:

$o='foo bar blah !' ;
$o =~ s/(\w+)/masked/g ;
print $o

masked masked masked !

not the expected

masked bar blah !


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source