Pattern matching, global and returning list 
Author Message
 Pattern matching, global and returning list

I tried to do this once long ago, but gave up because I couldn't figure
out the right pattern, and I ran out of time.  I've also looked at
archives but haven't been able to find the right set of keywords to
get the answer.  <g>

I have a text string that was created by join('',<FILE>), it consists
of bus schedules.  It will look something like this:

----
some lines

some lines

Monday through Friday Schedule
Eastbound
text \t text \t text \t
time \t time \t time \t
time \t time \t time \t

Westbound
text \t text \t text \t
time \t time \t time \t
time \t time \t time \t

Saturday Schedule
Eastbound
text \t text \t text \t
time \t time \t time \t
time \t time \t time \t

Westbound
text \t text \t text \t
time \t time \t time \t
time \t time \t time \t

--

Note that the days before the word "Schedule" will vary, as will the
direction before "bound".  And some files would also have a "Sunday"
Schedule line.

What I'm looking for is to create a list, in this case, consisting of 2
elements - #0 would be everything from "Monday throu Friday Schedule" up
to and including the blank line before "Saturday Schedule".  #1 would be
"Saturday Schedule" up to and including either the end of file (in this case)
or the possible "Sunday Schedule" - in which case there would be element #2
for Sunday.

I've tried various combinations of split and m/()/gs, but my main problem
has been the backwards matching, where #0 would contain everything up to
the first "Schedule", and #1 would be everything up to the next "Schedule".
I'll admit that I'm tired and my eyes are slowly losing focus.

Any and all help and suggestions are appreciated!  

Kind regards,
Ray Mullins
--
M. Ray Mullins Big Bear City, California home of the other MARTA ICQ# 28901695
California Transit Publications - your one stop shop for transit marketing,
publications, planning and web services at http://www.*-*-*.com/ ;   TIPs:
http://www.*-*-*.com/ http://www.*-*-*.com/ http://www.*-*-*.com/



Tue, 25 Feb 2003 05:21:40 GMT  
 Pattern matching, global and returning list
Thanks, Mark-Jason.  Part of my reason for posting (although not explicitly
mentioned <g>) was that someone might have a different way of solving the
problem.

It was a good learning experience - it now works using the paragraph
mode, although I have to pre-process the file - these files are exported
from M$-Excel and every once in a while it puts out lines that consist
only of tabs, and paragraph mode rightly doesn't recognize them as blank
lines.

Best regards,
Ray
--
M. Ray Mullins Big Bear City, California home of the other MARTA ICQ# 28901695
California Transit Publications - your one stop shop for transit marketing,
publications, planning and web services at http://www.catransit.com/     TIPs:
http://socaltip.tipnetworks.org http://norcaltip.tipnetworks.org http://cencaltip.tipnetworks.org



Tue, 25 Feb 2003 23:21:48 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. TQuery created on the fly..How to access fields without Fields Editor?

2. Can delphi compile pascal??

3. global pattern matching question

4. pos() and global pattern matching

5. global pattern match

6. Getting backreferences from global pattern match?

7. Pattern matching returns dupes in $n

8. Delphi2 DataBase Desktop GPF Error

9. Programming Win31 and Win95

10. list of pattern matches

11. making unique list of words matching a pattern

12. Pattern Matching with Lists?

 

 
Powered by phpBB® Forum Software