Solved

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

Posted on 2004-08-10
1
569 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now