On Thu, 2008-09-18 at 13:53 +0000, Tzafrir Cohen wrote:
> On Thu, Sep 18, 2008 at 02:29:29PM +0100, michael wrote:
> > I've been struggling to get this to work but I think 'sed' should be
> > able to do it if I could just get some help with the correct
> > incantation...
> > 
> > 
> > given a file with many strings, include many of the form
> >   <a href="some url or other">www</a>
> > 
> > I wish each to be transformed to
> >   <a href="some url or other">some url or other</a>
> > 
> > ie so literal 'www' is replaced with the actual URL for each
> > occurance... 
> 
> Maybe:
> 
>   sed -e '\(<a href="\([^"]*\)">\)www\(</a>\)|\1\2\3|g'
> 

yes, I've just worked out the subexpressions, thanks to most useful page
http://rute.2038bug.com/node11.html.gz#SECTION001170000000000000000


so for my particular case I can use
  sed -e 's%\(<a\ href\=\)\(\"\)\([^ ]*\)\(\"\)\(>www\)%\1\2\3\4\>\3%g' 

which is very sim to yours (NB my example here may not be precise since
I have copied it from a script which is doing something slightly
differently)

> -- 
> Tzafrir Cohen         | [EMAIL PROTECTED] | VIM is
> http://tzafrir.org.il |                    | a Mutt's
> [EMAIL PROTECTED] |                    |  best
> ICQ# 16849754         |                    | friend
> 
> 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to