My Mac sed does have an option similar to -r, it's -E:
This works for my PowerMac running Mac OS Tiger 10.4.11:
Code:
echo " 1234567890 " | \
sed -E '
: L
s=([0-9]+)([0-9]{3})=\1,\2=
t L'
But I must say that this version of sed does not accept semicolons (

in place of newlines.
Per archtoad's comments, 1,10,11: it's my pleasure. 2 can be answered above.
3. This will happen soon, hopefully.
4. Separate lines were necessary for me but you did improve the entry!
5. True but a good illustration of the use of \b.
6. My habit to put the -e option there is a mnemonic device to curb my zealousness!
7. I found the use of '=' as a delimiter to be original (to me) and instructive.
My use of / delimiters here is my custom derived from years of vi use and man reading.
I find slashes and vertical bars are visually helpful when reading replacement commands.
it's probably redundant here but the man page said it well:
"
Any character other
than backslash or newline can be used instead of a slash to
delimit the RE and the replacement. Within the RE and the
replacement, the RE delimiter itself can be used as a literal
character if it is preceded by a backslash.
"
8. "[0-9]+" is not allowed by my version of BRE. On impulse, I tried using the asterisk ("*")
but it caused sed to spin. "[0-9]{4,19}" leaves out the first comma in the example number.
9. "g", like my -e is unnecessary but did no damage either.
Reuti,
Good suggestion. I could not justify the trouble to learn the compile environment
until I saw the code from archtoad.