_Why_, in sed and perl, does the s/foo/bar/ syntax default to substituting just one occurrence, and not all of them?

I can't immediately remember any situation where that was specifically what I wanted. And I can remember lots of situations where I was caught out by forgetting to add the 'g' flag on the end. (One of them three minutes ago, oddly enough.)

Why isn't 'g' the default, and 'only substitute once' a special option you have to select?

0
0
0

If you have a fediverse account, you can quote this note from your own instance. Search https://hachyderm.io/users/simontatham/statuses/116023796973712357 on your instance and quote it. (Note that quoting is not supported in Mastodon.)