A few points:
You use /
as the delimiter for sed
but the substitution contains /
so choose a different delimiter such as |
or escape the /
in the substitution with \
. Any delimiter can used with sed
.
The quantifier {n}
is part of the extended regexp class so use the -r
option (or -E
for BSD derivatives of sed
) or again escape the extended features like \{2\}
.
The g
flag may or may not be needed depending if you have multiple matches on a single line. It doesn't make a difference for your given example but it's worth pointing out.
You probably want {1,2}
for the days and months i.e 1/1/2012
.
I would do:
$ sed -r 's|somedate:"[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}"||' file
something and and something else
Alternatively by escaping everything:
$ sed 's/somedate:"[0-9]\{1,2\}\/[0-9]\{1,2\}\/[0-9]\{4\}"//' file
something and and something else