sed 'iteration character' question

I'm processing ( trying to anyway ) a file of pipe delimited database output.

Sample record:

365026 | ocn424525329 | With his lightening-quick hands and feet

The second field in the above data is "ocn424525329". It should be
"424525329" with no trailing or leading spaces. This may be better approached with awk but while I try that I thought I'd ask something that's been bothering me about sed's iteration metacharacter: {n} or {n,m}.

For example, suppose I want to replace this field with the word 'hello' ...

Why can I not match this with:

sed 's/ocn[0-9]{9}/hello/g' tmp

???

No matter what I try the {n} meta sequence does nothing.

Bub

---------- Post updated at 07:02 PM ---------- Previous update was at 06:55 PM ----------

The following matches:

sed 's/oc[nm][0-9]\{8,9\} /hello/g' tmp

So I have to escape the braces. When un-escaped, I assume that they are
taken literally?

thanks ~

Bub

Yes, you are right. sed uses POSIX regular expressions, which are almost, but not completely, like Perl regular expressions. Character classes work almost the same, but matching groups and repetition require their braces to be escaped.

Thanks ~

Handy tool once you get the rules down!

Bub