Thread suchen & ersetzen multiline (3 answers)
Opened by micneu at 2011-04-05 14:32

micneu
 2011-04-05 14:32
#147391 #147391
User since
2008-11-27
13 Artikel
BenutzerIn
[default_avatar]
ich habe eine datei, die wird von wpkg erstellt.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<wpkg><package id="acrobat8" name="Acrobat Reader 8.1.2" revision="812" reboot="false" priority="10">
<check type="uninstall" condition="exists" path="Adobe Reader 8.1.2 - Deutsch"/>
<install cmd="msiexec /q /i &quot;%SOFTWARE%\pkg\adobe\AcroRead.msi&quot; allusers=1">
<exit code="0"/>
</install>
<remove cmd="MsiExec.exe /q /x{AC76BA86-7AD7-1031-7B44-A70500000002}"/>
<upgrade cmd="msiexec /q /i &quot;%SOFTWARE%\pkg\adobe\AcroRead.msi&quot; allusers=1">
<exit code="0"/>
<exit code="3010"/>
</upgrade>
</package>
<package id="ReportViewer" name="Microsoft Report Viewer Redistributable 2008" revision="2" reboot="false" priority="10">
<check type="uninstall" condition="exists" path="Microsoft Report Viewer Redistributable 2008"/>
<install cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /q">
<exit code="0"/>
</install>
<remove cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /qu"/>
</package>
<package id="pdfcreator" name="PDFCreator" revision="091" priority="0" reboot="false">
<check type="uninstall" condition="exists" path="PDFCreator"/>
<install cmd="msiexec /qb /i &quot;%SOFTWARE%\pkg\pdfcreator\PDFCreator-0_9_1_AFPLGhostscript_32bit.msi&quot;"/>
<install cmd="rundll32 printui.dll,PrintUIEntry /q /ga pdfcreator"/>
<remove cmd="MsiExec.exe /q /x{0001B4FD-9EA3-4D90-A79E-FD14BA3AB01D}"/>
<upgrade cmd=""/>
</package>

....


wie kann ich jetzt den block suchen (finden)
Code: (dl )
1
2
3
4
5
6
7
<package id="ReportViewer" name="Microsoft Report Viewer Redistributable 2008" revision="2" reboot="false" priority="10">
<check type="uninstall" condition="exists" path="Microsoft Report Viewer Redistributable 2008"/>
<install cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /q">
<exit code="0"/>
</install>
<remove cmd="%SOFTWARE%\pkg\wsus\ReportViewer.exe /qu"/>
</package>


mit dem code unten finde ich alles bis zum ende der datei.
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl -w

open(INFILE, "</test.xml") or die "Can't open input.txt: $!";
open(OUTFILE, ">output.txt") or die "Can't open output.txt: $!";

my $string = do { local $/; <INFILE> };
my $text = $string;
#print $string;
$text =~ s/(<package id="ReportViewer" name="M.*<\/package>)//ms;
#print $text;
print $&;
print OUTFILE $text;
close INFILE;
close OUTFILE;


hoffe ihr könnt mir helfen.

gruß michael
Last edited: 2011-04-05 14:34:07 +0200 (CEST)

View full thread suchen & ersetzen multiline