Solved

Regex problem: period not matching newline in s///s?

Posted on 2004-08-10
1
573 Views
Last Modified: 2011-09-20
Here's my perl script:

#!C:/perl/bin/perl.exe -Wpi.orig
s#<RD:Documento>([0-9]{1,4})( D\.?P\.?R\.? )([0-9]{1,4})(.*Juez.*</TA>)#<RD:Documento>$1$2$3$4\n<CM>HTMLINSERT:<a href="/Download/DPR4/Sumarios_Escolios/Tomo$1/$1DPR$3-Escolio.pdf" target=centerframe><center><font face=Arial size=1>Ver Escolio</A></CM>\n#s;

And here's my text file, between but not including "---"s:
---

<RD>Así lo pronunció y manda el Tribunal y lo certifica el señor Secretario General. El Juez Presidente señor Andréu García y el Juez Asociado señor Negrón García inhibidos. El Juez Asociado señor Rebollo López no intervino. <CM>LineFeed</CM>

<RD><CM>LineFeed</CM>

<RD>Francisco R. Agrait Lladó, Secretario General <CM>LineFeed</CM>

<RD><CM>LineFeed</CM>

<RD><PB>
<RD>
<RD:Documento>135 DPR 259 --  In Re: Colton, Villanueva, Miró, Figueroa, Brunet
<RD>
<RD>
<TA:1,1; JU:LF; BR:AL:0.00972222,0.0298611,HZ:0.00972222,0.0298611,VT:0.00972222,0.0298611>
<RO><CE: HI; VA:CN><JU:CN><CM>HTMLINSERT:<a href="/Download/DPR4/135/135_259.DOC" target=centerframe><center><font face=Arial size=1>Grabar la Decisión</A></CM>
</TA>

<RD>
<TA:2,1.5,3.5; JU:CN; BR:AL:0.00972222,0.0298611,HZ:0.00972222,0.0298611,VT:0.00972222,0.0298611; SD:255,255,0>
<RO><CE: MR:1; SD:0,0,128><JU:CN><CM>C Ta info</CM>
<BD+><FC:255,255,255><BC:DC>Información del Documento<IT+><FC><BC></CE>
<RO><CE><FT:Arial,SR><PT:8>Partes:<BD></CE><CE><FD:Nombre>In re: Pedro Colton Fontán, Osvaldo Villanueva Díaz, Aurelio Miró Carrión, Angel Figueroa Vivas, Juan E. Brunet Justiniano</FD:Nombre></CE>
<RO><CE><BD+>Fecha:<BD></CE><CE><FD:Fecha><HD+>3/4/1994</FD:Fecha><HD>4 de marzo de 1994<BD+></CE>
<RO><CE>Cita:<BD></CE><CE><FD:DocID><HD+> 135DPR259</FD:DocID><HD->  135 DPR 259</CE>
<RO><CE><BD+><HD>Juez:<BD><HD-></CE><CE> <FD:Autor><BD-> Resolución</FD:Autor><BD+></TA>

<RD>
<RD:Seccion>Opinión
<RD>
<RD:Pagina>Página: 259
<RD>
<RD>CE-86-666<CM>MJSEP</CM>
<HR>
<RD><CM>MJSEPEND</CM>
Conducta Profesional<CM>MJSEP</CM>
<HR>
---

According to this app I downloaded, The Regex Coach, the regex matches a good chunk of the file, specifically from the beginning of the line starting with <RD:Documento> until the end of the line that contains "Juez", but the script does nothing.  When I fiddle with the regex to pinpoint the problem, I find that up to the end of the third expression it does match as I expect, but when I add in the fourth, (.*Juez.*</TA>), it stops working. Does it have something to do with the newlines that should be matched by that expression?

Thanks!
0
Comment
Question by:madacebo
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 11768315
Try
#!C:/perl/bin/perl.exe -0777 -Wpi.orig
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hard perl script 16 157
Removing file extension within a file. 4 93
ppm conversion to curl on a module install 8 82
.properties file to call function/method 9 61
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question