Solved

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

Posted on 2004-08-10
1
581 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Six Sigma Control Plans

689 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