language: Perl (perl 5.16.2)
date: 204 days 10 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$s = <<__END;
random overhead
[oracle\@ipda04]\$ hostname
ipda04</IA%EXAMPLE>
text here
[source]
anything here
<IA%COMMAND>stuff to print </IA%COMMAND>
<IA%xxx>test</IA%xxx>
stuff that should be ignored
[oracle\@ipda04]\$ hostname
ipda04</IA%EXAMPLE>
text here
[target]
<IA%UICOMMAND>other stuff to print</IA%UICOMMAND>
stuff to be ignored
[target]
<IA%COMMAND>print out this too
and this as well </IA%COMMAND>
__END
 
$s =~ s/(?:\A.*?(?=^\[[^[\]]*\](?:\n|\z)|\z)|(?<=[>\]]\n)(?!\[[^[\]]*\]*(?:\n|\z)|<[^>]*COMMAND>).*?(?=^\[[^[\]]*\](?:\n|\z)|^<[^>]*COMMAND>|\z))//gms;
 
print($s);
  • upload with new input
  • result: Success     time: 0s    memory: 4596 kB     returned value: 0

    [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>