Regular Expressions

..:: sjf ::.. sjf at autograf.pl
Tue Apr 27 07:49:37 EDT 2004


pewnego dnia niejaki Diez B. Roggisch deetsNOSPAM at web.de wstukał był ;-)
>> <FONT COLOR="#FF0000">A - TYPE1: any_text<BR>
>> B - TYPE2: any_text_2<BR>
>> C - TYPE2: any_text_3<BR>
>> w - any_text_15<BR>
>> </FONT>
>> html code
>> </BODY></HTML>
>> I need to have only following data:
>> (B, any_text_2)
>> (C, any_text_3)
>> that is, these data TYPE2 in which.
> you should utilize the htmlparser class to extract the text first. Then
> this regular expression might help:
> r"(.) TYPE. : (.*)"

Thanks. And now, let's assume that I have a following strings:
S1 = "B - TYPE2: any_text_2 TYPE3: any_text_23"
S2 = "C - TYPE2: any_text_3"

and I want to have one regular expression that produce only following data:
("B", "any_text_2")
("C", "any_text_3")
that is, any characters starting TYPE3 till end will be omitted.
How do make this?

-- 
.:: sjf ::..
"Linux is like Wigwam. No gates, no windows... Apache inside ;-)"



More information about the Python-list mailing list