D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] perl substitutions

 

On Thu, Apr 10, 2008 at 12:19 PM, stinga wrote:
>  I have
>  blah blah [[here_is_some_text|and a bit more]]
>
>  I want it to look
>  blah blah [[here is some text|and a bit more]]
>
>  I can do it with a bunch of code, but I could really do with it being on one line.
>  I can do...
>  $a =~ s/\[\[(.*)_(.*)\]\]/\]\]$1 $2\]\]/
>  and nearly get there, but it only does one _
>
>  Any suggestions?

How about

while ($a =~ s/\[\[(.*)_(.*)\]\]/\[\[$1 $2\]\]/) {}

?

Haven't tested this but all I did was add a while ($a =~ ... ) {} and
then correct a typo.

Martijn.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html