[Tutor] re module / separator
Tiago Saboga
tiagosaboga at gmail.com
Wed Jun 24 22:42:15 CEST 2009
Serdar Tumgoren <zstumgoren at gmail.com> writes:
> Hey Tiago,
>
>> text = "a2345b. f325. a45453b. a325643b. a435643b. g234324b."
>>
>> Of this line of text, I want to take out strings where all words start
>> with a, end with "b.". But I don't want a list of words. I want that:
>>
>> ["a2345b.", "a45453b. a325643b. a435643b."]
>>
>
> Are you saying you want a list of every item that starts with an "a"
> and ends with a "b"? If so, the above list is not what you're after.
> It only contains two items:
> a2345b.
> a45453b. a325643b. a435643b.
Yes, I want to find only two items. I want every sequence of words where
every word begins with an "a" and ends with "b.".
> Try reading this:
> http://www.amk.ca/python/howto/regex/
I have read several times, and I thought I understood it quite well ;)
I have not the time right now to do it, but if it turns out to be
useful, I can show why I came to the patterns I sent to the list.
Thanks,
Tiago.
More information about the Tutor
mailing list