re Insanity

Tim Daneliuk tundra at tundraware.com
Wed Jan 26 05:48:19 EST 2005


Aahz wrote:
> In article <4ln9c2-0mh1.ln1 at eskimo.tundraware.com>,
> Tim Daneliuk  <tundra at tundraware.com> wrote:
> 
>>Given an arbitrary string, I want to find each individual instance of
>>text in the form:  "[PROMPT:optional text]"
>>
>>I tried this:
>>
>>    y=re.compile(r'\[PROMPT:.*\]')
>>
>>Which works fine when the text is exactly "[PROMPT:whatever]" but
>>does not match on:
>>
>>   "something [PROMPT:foo] something [PROMPT:bar] something ..."
>>
>>The overall goal is to identify the beginning and end of each [PROMPT...]
>>string in the line.
>>
>>Ideas anyone?
> 
> 
> Yeah, read the Friedl book.  (Okay, so that's not gonna help right now,
> but trust me, if you're going to write lots of regexes, READ THAT BOOK.)

I've read significant parts of it.  The problem is that I don't write
re often enough to recall all the subtle details ... plus I am getting
old and feeble... ;)

-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/



More information about the Python-list mailing list