What is the best method to match a pattern in set of lines

Lie Ryan lie.1296 at gmail.com
Sat Jun 20 15:58:59 EDT 2009


Dennis Lee Bieber wrote:
> On Fri, 19 Jun 2009 17:52:05 -0700 (PDT), Terminator
> <manidevarajan at gmail.com> declaimed the following in
> gmane.comp.python.general:
> 
>> Hello,
>>  My requierment is to get the "Stick Tag" value from the below o/p and
>> based on tag take different actions. What is the best way to implement
>> it. I am new to Python, so appreciate any input.
>>
>> Command o/p:
>> ===================================================================
>> File: Packet.tcl        Status: Needs Merge
>>
>>    Working revision:    1.2.98      Result of merge
>>    Repository revision: 1.2.99      /auto/quality/CVS/tools/ext/
>> Packet.tcl,v
>>    Sticky Tag:          rel-ip-branch (branch: 1.584.2)
>>    Sticky Date:         (none)
>>    Sticky Options:      (none)
>>
>> Requirement:
>> If "Sticky Tag" is rel-ip-brach
>>   do A
>> else "Sticky Tag" is rel-ipv6-branch
>>   do B
>>
>> Thanks in advance.
> 
> 	Sounds like homework -- but rather advanced if the homework is to
> extract/parse stuff from a CVS repository...
> 
> 
> Step one: find the line with "Sticky Tag:"
> 	I presume you can code an I/O loop reading lines from a file... in
> that case, look at:
> 		if "Sticky Tag:" in line:
> 
> Step two: once the line is found; extract the word after the field
> identifier...
> 
> Step three: 
> 		if word == "rel-ip-branch": # I'm presuming brach is typo

Regular expression?



More information about the Python-list mailing list