Reputation: 828
I need to replace a specific part of a link
for example:
http://sub.somedomain.com/s/be2b46b4cb28ed64fe59d191cb600117/2013/image.jpg
to
http://sub.somedomain.com/s/123123/2013/image.jpg
what I've tried:
echo "http://sub.somedomain.com/s/be2b46b4cb28ed64fe59d191cb600117/2013/image.jpg" | sed "s@/s/(.+?)/@123123@g"
Upvotes: 5
Views: 143
Reputation: 2017
sed "s@/s/[^/]*/@/s/123123/@g"
Problems with your regex:
(
and )
are regular characters in basic regular expressions (BRE) (and they are not really needed here)+
is also not special in BREsed -E
, you would match too much because you don't stop at the next slashUpvotes: 5