6

It is my sed.

sed 's/\([a-z]\)\([A-Z]\)\([0-9]\)\([a-z]\)\([A-Z]\)\([0-9]\)\([a-z]\)\([A-Z]\)\([0-9]\)\([a-z]\)/\10/g'

I tried to get 10th grouping value.But,It gives first grouping value with 0(zero).

How to get 10th grouping value?

whether it is possible to get the 10th grouping value?

sat
  • 14,589
  • 7
  • 46
  • 65

1 Answers1

6

sed only supports 10 groups(from \0 to \9), and doesn't support non-captured group.

You can rewrite you command as:

sed 's/[a-z][A-Z][0-9][a-z][A-Z][0-9][a-z][A-Z][0-9]\([a-z]\)/\1/g'
kev
  • 155,172
  • 47
  • 273
  • 272
  • @ kev , Thank you.. \1 is used to get the first group values.what is the use of \0? which scenario i have to use \0? can you give some guideline for that. – sat Jun 12 '12 at 09:18
  • 1
    You can try `python`. It has `named-group`. Regexp is much clear when groups have names. – kev Jun 12 '12 at 09:38
  • 3
    In some sed's `\0` is an alias for `&` i.e. the whole of the LHS matching pattern. – potong Jun 12 '12 at 12:07