I was trying to format a list of library hours at a university library to
later enter into my Visor so I started to write a Perl script to do so.  An
example of the text I was trying to modify is below:

UNDERGRADUATE(UG) 

                                Undergraduate Library Bldg., 333-1031; M -
Th: 8am - 1am; F: 8am - 10pm; Sa: 9am - 10pm; Su: 1pm - 1am 

                           UNIVERSITY ARCHIVES (AH) 

                                19 Library, 333-0798; M - F 8:30am - 5pm 

                                SEE ALSO ARCHIVES RESEARCH CENTER. 

What I wanted it to eventually look like was this:

UNDERGRADUATE(UG)Undergraduate Library Bldg., 333-1031; M - Th: 8am - 1am;
F: 8am - 10pm; Sa: 9am - 10pm; Su: 1pm - 1am 

UNIVERSITY ARCHIVES (AH) 19 Library, 333-0798; M - F 8:30am - 5pm SEE ALSO
ARCHIVES RESEARCH CENTER.

So to start out I wrote this RegEx which I thought would match the
capitalized text and the two new line feeds and then I was going to replace
the match with just the capitalized text.  This was my first stab at it:

s/\([A-Z]{2,}\)*\n\n/<$1>/g

Yeah, kinda ignorantly structured, but it was my first attempt.  To just see
what would be matched without the substitution I simplified it to just this:

[A-Z]{2,}*\n\n

Surprisingly it matched the newline feeds and all the white space between
the newline feeds up to the next occurance of all capital letters!  Well
this worked too since I then just deleted what it matched and basically
accomplished what I was trying to do in the first place.

        So my question is, why did this match what it did instead of what I
thought it would match?



Scott Johnson

_________________________________________________________________
                                C I S C O  S Y S T E M S
                                Engineering Release Management
                                ISM Group
                                Champaign, Illinois
 
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to