in reply to Re^3: A text replacement question
in thread A text replacement question

Looking at one of the files you would see would see;

AAvIY
AAvT
AAvY
AAvHH
TvHH
ZHvTH
DHvZH

...
and many, many more!
And what im expecting as output is

(for 13v13 - im using letters in my code though!)
<INPUT TYPE=radio NAME=13v13 VALUE='' CHECKED>three & six
weak<INPUT TYPE=radio NAME=13v13 VALUE=1><INPUT TYPE=radio NAME=13v13 VALUE=2><INPUT TYPE=radio NAME=13v13 VALUE=3><INPUT TYPE=radio NAME=13v13 VALUE=4><INPUT TYPE=radio NAME=13v13 VALUE=5><INPUT TYPE=radio NAME=13v13 VALUE=6><INPUT TYPE=radio NAME=13v13 VALUE=7>strong


so for AAvBB i'd want to get; weak<INPUT TYPE=radio NAME=AAvBB VALUE=1> <INPUT TYPE= radio NAME=AAvBB VALUE=2>....<INPUT TYPE radio NAME=AAvBB VALUE=5>strong


. ideally id like the regex to operate on xvx but not NAME=xvx. Hope that helps

Replies are listed 'Best First'.
Re^5: A text replacement question
by Animator (Hermit) on Feb 15, 2005 at 15:35 UTC

    That sure helps.

    You can do this via a one-liner or via real code.

    (untested one-liner):

    perl -pi.bak -e 's/(?!<NAME)(\w{2}v\w{2})/&replace($1)/ieg; BEGIN { sub replace { my $name = shift; return "<input type=..... name=$name>...."; } }' *.html

    All you need to do now, is modify the replace subroutine.