in reply to Re^2: detection in Loop condition
in thread detection in Loop condition

Do you mean your input file is an XML-file, but with the <body> tag not closed or closed at a wrong place? If the <body> tag is not closed then your XML-file is invalid and you better remedy that first.

If you just want to move the <body> tag to some other place (which means you want to re-order your XML-tree structure) then consider that XML-files are best handled with one of the many XML-parsers and not with regexes.

If you can show a (small / stripped down, but still relevant) example of your XML-file, you will get a much better reply from the Monks here.

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