Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

14 Experts available now in Live!

Get 1:1 Help Now