in reply to Replace XML tag names.
s{(<[^\s?!>]+)}{(my $tagname = $1 ) =~ tr/.//d;$tagname;}eg;
Yes that will cause the substitiution part to trigger even when there are no dots in the tagname, but it makes the whole of the regex much simpler and easier to understand and debug.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Replace XML tag names.
by Jenda (Abbot) on May 04, 2010 at 11:25 UTC |