Trick is, to limit them very carefully by specifying what they are to match. Watch .* - I always use .*? myself.
For instance, for one of your strings, which ends with the ESC=<single character>k(some whitespace or not)0 \x1b.*?0 would certainly match that, but it'd also match ESC foo ### # ESC=#k0 Whereas \x1b\=.k\w*?0 would match it far more precisely, because that's the regex for esc=<single character*>k<some whitespace, maybe>0 *excluding \n unless the flag re.DOTALL is used. So yeah; something else to note, certain characters need to be escaped in regex strings. Namely, these ones - .^$*+?{[|( That second to last one is a pipe by the way, not an I. And * is very greedy, but a ? limits it's greediness greatly. Good luck, Liam Clarke On 4/21/06, doug shawhan <[EMAIL PROTECTED]> wrote: > I am discovering that. They tend to get all Ayn Rand on you and grab too > much. :-) > > > On 4/20/06, Liam Clarke <[EMAIL PROTECTED] > wrote: > > Yeah, Alan's tutorial is what I used to learn how to code, it's very good. > > Regexes are very powerful; which can be a very good thing and a very > > bad thing. ;) > > > > Good luck. > > > > On 4/20/06, doug shawhan <[EMAIL PROTECTED]> wrote: > > > Got it! Thanks! Mr. Gald hooked me up with his re tutorial as well. > Great! > > > > > > > > > On 4/19/06, Liam Clarke <[EMAIL PROTECTED] > wrote: > > > > Here's my copy, it should work if you have Tkinter. > > > > > > > > Good luck! > > > > > > > > On 4/20/06, doug shawhan <[EMAIL PROTECTED]> wrote: > > > > > Drat, I installed from the OpenBSD ports tree and this is not > included. > > > I'll > > > > > scout around on the net. > > > > > > > > > > Thanks again! > > > > > > > > > > > > > > > On 4/19/06, doug shawhan < [EMAIL PROTECTED]> wrote: > > > > > > > > > > > > Holy moley. > > > > > > > > > > > > Thanks! > > > > > > > > > > > > > > > > > > > > > > > > On 4/19/06, Liam Clarke < [EMAIL PROTECTED]> wrote: > > > > > > > Hi Doug, > > > > > > > > > > > > > > Best tip ever is > > > > > your_python_dir\tools\scripts\redemo.py > > > > > > > > > > > > > > Interactive regexes. :) > > > > > > > > > > > > > > This is pretty good as well - > > > > > http://www.amk.ca/python/howto/regex/ > > > > > > > > > > > > > > Good luck, > > > > > > > > > > > > > > Liam Clarke > > > > > > > > > > > > > > On 4/20/06, doug shawhan < [EMAIL PROTECTED]> wrote: > > > > > > > > I think I'm going to have to suck it up and learn some regular > > > > > expressions. > > > > > > > > > > > > > > > > I have finally gotten my script (using the excellent pyserial > > > module) > > > > > to > > > > > > > > behave. Most of my troubles as enumerated here before were > utterly > > > > > > > > self-induced. Apparently one cannot watch the execution of > one's > > > > > script > > > > > > > > through another program without affecting it's outcome in > > > unforseen > > > > > ways. > > > > > > > > (Sound familiar Herr Schroedinger? :-) > > > > > > > > > > > > > > > > Now that I am actually extracting data in a fairly > predictable > > > way, I > > > > > am at > > > > > > > > the point where I need to parse it! I have some output here > > > (modified > > > > > to > > > > > > > > show the ESC and NUL characters.) > > > > > > > > > > > > > > > > When I pull data from the port, the remote computer sends it > in > > > one > > > > > long > > > > > > > > string per screen: newlines are not painted in by using the > > > expected > > > > > x\0a > > > > > > > > that I had hoped for! No easy readlines() fun for me. Instead > I > > > get: > > > > > > > > > > > > > > > > ESC=( 1. ESC=($4x2, 6-239 ( 3.9L) > > > > > > > > > > > ..........................................ESC=(a03252 > > > > > > > > ESC=(k0 > > > > > > > > ESC=) 2. ESC=))8-318 ( 5.2L) > > > > > > > > > > > ..........................................ESC=)a03242 > > > > > > > > ESC=)k0 > > > > > > > > ESC=* 3. ESC=*)8-360 ( 5.9L) > > > > > > > > > > > ..........................................ESC=*a03351 > > > > > > > > ESC=*k 0 > > > > > > > > ESC=+ 4. ESC=+$4x4, 6-239 ( 3.9L) > > > > > > > > > > > ..........................................ESC=+a03240 > > > > > > > > ESC=+k 0 > > > > > > > > ESC=, 5. ESC=,)8-318 (5.2L) > > > > > > > > > > > ..........................................ESC=,a03243 > > > > > > > > ESC=,k 0 > > > > > > > > ESC=- 6. ESC=-)8-360 ( 5.9L) > > > > > > > > > > > ..........................................ESC=-a03352 > > > > > > > > ESC=-k 0 > > > > > > > > ESC=. 7. ESC=.aCH8299 ESCTNULESC)NULESC=% > > > > > LINEESCTNULESC=& R = > > > > > > > > RELIST <return> = NONE > > > > > > > > > > > > > > > > I have broken it up for ease of viewing. I need to split the > > > string > > > > > where > > > > > > > > ESC= , k and 0 are found, but ESC= ,k and 0 are seperated by > > > various > > > > > > > > spaces, parentheis and other characters that are apparently > used > > > to > > > > > mark the > > > > > > > > end of the line until the next ESC is found, thereby > displaying a > > > new > > > > > line > > > > > > > > (note how the character after the first ESC on each line is > > > repeated > > > > > after > > > > > > > > the ESC on the end. > > > > > > > > > > > > > > > > I cannot for the life of me figure out a pythonic way (read: > > > using > > > > > the > > > > > > > > split() builtin) to scan for instances of these characters in > such > > > and > > > > > such > > > > > > > > order and proximity. I know this is what regex is for, but I > have > > > no > > > > > > > > experience. I have obtained a copy of "Mastering Regular > > > Expressions" > > > > > but > > > > > > > > thought I would inquire here first for caveats and tips as the > > > book is > > > > > > > > larger than my brain, and I haven't used the re module, ever. > > > > > > > > > > > > > > > > Why in the world does this make me so happy? :-)~ > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > Tutor maillist - Tutor@python.org > > > > > > > > http://mail.python.org/mailman/listinfo/tutor > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor