Regular expressions question
Neil Cerutti
horpner at yahoo.com
Tue Jan 16 10:01:19 EST 2007
On 2007-01-16, Victor Polukcht <vpolukcht at gmail.com> wrote:
> On Jan 16, 5:40 pm, Neil Cerutti <horp... at yahoo.com> wrote:
>> On 2007-01-16, Victor Polukcht <vpoluk... at gmail.com> wrote:
>>
>> > Actually, i'm trying to get the values of first field (Global) , fourth
>> > (200, 4), and fifth (100%) and sixth (100%).
>>
>> > Everything except fourth is simple.
>> >>> g = "Global etsi3 * 4 ok 30 100% 100% Outgoing"
>> >>> import re
>> >>> r = re.search('\*\s+(\d+)', g)
>> >>> r.group()
>> '* 4'
>> >>> r.group(1)'4'
>
> The same regular expression should work for another string (with *200).
Sorry about that. It should have been:
r = re.search('\*\s*(\d+)', g)
--
Neil Cerutti
More information about the Python-list
mailing list