Tempo <br*******@gmail.com> wrote:
I've been reading a bunch of articles and tutorials on the net, but I
cannot quite get ahold of the whole regular expression process. I have
a list that contains about thirty strings, each in its own spot in the
list. What I want to do is search the list, say it's called 'lines',
for 'R0 -'.
No need for regular expressions for this task as you expressed it:
for aline in lines:
if 'R0 -' in aline:
doyourworst(aline)
I've sweated substantial amount of blood and other bodyfluiids trying to
explain "the whole regular expresson process" concisely and effectively
in chapter 9 of "Python in a Nutshell" (and I'm going through the
heartache of preparing the second edition now -- let's say I'm currently
grasping for any straw to avoid the work;-) -- if I didn't do a good
enough job there, I sure can't do better here. But one thing stands: if
you don't yet understand fully the abilities of Python's strings and
other builtins, as for example in the above snippet, studying REs is
premature. WAY premature.
Alex