We don't bite newbies here... much | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
As a start-tag is not allowed to contain whitespace (since whitespace is used as a delimiter between the tag and the attributes) or the > character, the character class of excluded characters should only contain these two characters. For good measure I have added ? and ! to exclude xml-headers, doctype elements, processings instructions and the like.
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 In reply to Re: Replace XML tag names.
by CountZero
|
|