fork(2) download
  1. $s = <<__END;
  2. random overhead
  3. [oracle\@ipda04]\$ hostname
  4. ipda04</IA%EXAMPLE>
  5. text here
  6. [source]
  7. anything here
  8. <IA%COMMAND>stuff to print </IA%COMMAND>
  9. <IA%xxx>test</IA%xxx>
  10. stuff that should be ignored
  11. [oracle\@ipda04]\$ hostname
  12. ipda04</IA%EXAMPLE>
  13. text here
  14. [target]
  15. <IA%UICOMMAND>other stuff to print</IA%UICOMMAND>
  16. stuff to be ignored
  17. [target]
  18. <IA%COMMAND>print out this too
  19. and this as well </IA%COMMAND>
  20. __END
  21.  
  22. $s =~ s/(?:\A.*?(?=^\[[^[\]]*\](?:\n|\z)|\z)|(?<=[>\]]\n)(?!\[[^[\]]*\]*(?:\n|\z)|<[^>]*COMMAND>).*?(?=^\[[^[\]]*\](?:\n|\z)|^<[^>]*COMMAND>|\z))//gms;
  23.  
  24. print($s);
Success #stdin #stdout 0s 4596KB
stdin
Standard input is empty
stdout
[source]
<IA%COMMAND>stuff to print </IA%COMMAND>
[target]
<IA%UICOMMAND>other stuff to print</IA%UICOMMAND>
[target]
<IA%COMMAND>print out this too
and this as well </IA%COMMAND>