2

I am using telnetlib to telnet my device. the device return variable length records priodically with NO delimeter.

every record has a date and time in the begining of itself, which I can use as a delimeter.

How can I use Telnet.expect(list[, timeout]) to separate records.

Example Stream:

10/20/12_17:58:24 TEXT TEXT TEXT TEXT ..........
                  TEXT TEXT TEXT TEXT ..........
                  TEXT TEXT TEXTTEXT ..........
                  TEXT TEXT TEXTTEXT ..........

10/20/12_17:58:28  TEXT TEXT TEXTTEXT ..........
     TEXT TEXT TEXTTEXT .......... TEXT TEXT TEXTTEXT .......... TEXT TEXT TEXTTEXT ..

10/20/12_17:58:34  TEXT TEXT TEXTTEXT ..........
                 TEXT TEXT TEXTTEXT ..........
                 TEXT TEXT TEXTTEXT ..........

10/20/12_17:59:25  TEXT TEXT TEXTTEXT ..........
      TEXT TEXT TEXTTEXT ..........
Adel
  • 21
  • 2
  • I think the "block quoting" or indentation of your sample needs a few tweaks. The lines of all asterisks are being interpreted as horizontal rules. – Warren Weckesser Oct 20 '12 at 14:47
  • "block qouting" tweaked, I need records with their Date and Time (first row in any record) – Adel Oct 20 '12 at 14:58

1 Answers1

0

It seems that each line starts with white-space, if it is not a first line of the record.

If that is correct, then use regex pattern ^(?!\s) or [\n\r](?!\s) as a delimeter.

If that is not correct, then as a delimiter use regex pattern ^(?=\d+\/\d+\/\d+_\d+:\d+:\d+\s) or [\n\r](?=\d+\/\d+\/\d+_\d+:\d+:\d+\s)

Ωmega
  • 42,614
  • 34
  • 134
  • 203