-
SED
Is it possible to mix and match regexp in sed? Code:
sed 's#(\[0-9]\{1,2\}\)/\1/\1#11/17/79#' somefile
I'm assuming that should evaluate to Code:
sed 's#[0-9]\{1,2\}/[0-9]\{1,2\}/[0-9]\{1,2\}#11/17/79#' somfile
-
No, it doesn't. Try reading regex(7). \1 is a backreference, which means that it doesn't match the same regexp as the parenthesized subexpression that it refers to, but it matches the same text that was previously matched by that parenthesized subexpressions.
For example, while your second example matches 01/02/03, 11/58/97 and whatever, the first one only matches eg. 01/01/01, 52/52/52 and the likes. You get it?