s/cat|dog/snake/g
< The zoo had wild dogs, bobcats, lions, and other wild cats.
> The zoo had wild snakes, bobsnakes, lions, and other wild snakes.
s/[a-z]+i[a-z]*/nice/g
< The zoo had wild dogs, bobcats, lions, and other wild cats.
> The zoo had nice dogs, bobcats, nice, and other nice cats.
|
Most of the time, if you are using regular expressions to
modify a target text, you will want to match more general
patterns than just literal strings. Whatever is matched is what
gets replaced (even if it is several different strings in the
target)
|