Pls, help me with re
Alex Martelli
aleax at aleax.it
Mon Mar 3 05:35:33 EST 2003
Eric Brunel wrote:
> Lexy Zhitenev wrote:
>> Hi, All.
>>
>> I want to match a number if it is the only one in the string, and the
>> second one, if '=' preceeds it.
>>
>> Example
>>
>> 'Course: 23,95' - matches '23,95'
>> '$1 = 23,95 y' - matches '23,95'.
>
> So what you want is the following:
> - either a sequence of characters that are not equal signs, digits or
> commas, followed by a number, followed by a group of characters that are
> not equal signs, digits or commas
> - or a group of any characters, followed by an equal sign, followed by a
> group of characters that are not digits or commas, followed by a number,
> followed by anything
>
> Is that correct?
If your interpretation of these specs is correct, then I must be
missing some subtle interpretation of English words such as "second"
and "number". For example:
rah, rah, rah, 47!
this meets neither of your cases, yet "the only [number] in the string"
would seem to be pretty obviously "47" -- what am I missing?
Or, consider:
123 cats, 27 rats, 99 penguins = 249 animals
this WOULD appear to meet your second case, but "the second [number]"
does NOT meet the "if '=' preceeds it" clause in the specs -- yet you
would appear to match based on the FOURTH number, which does meet
said clause. What am I missing here?
Alex
More information about the Python-list
mailing list