Terry Hancock wrote:
> I think this is the "regexes can't count" problem. When the repetition
> count matters, you usually need something else. Usually some
> combination of string and list methods will do the trick, as here.
Not exactly, regexes are just fine at doing things like "first" and
"l
On Thursday 21 July 2005 11:39 pm, Felix Collins wrote:
> Christopher Subich wrote:
> > Scott David Daniels wrote:
> Thanks to you both. Wow! what a quick response!
> >string.rsplit('.',1)[0]
> Clever Python! ;-)
> Sorry, I mainly code in C so I'm not very Pythonic in my thinking.
> Thanks agai
Felix Collins wrote:
> Hi,
> I'm not a regexp expert and had a bit of trouble with the following search.
> I have an "outline number" system like
> 1
> 1.2
> 1.2.3
> I want to parse an outline number and return the parent.
Seems to me regex is not the way to go:
def parent(string):
Hi,
I'm not a regexp expert and had a bit of trouble with the following
search.
I have an "outline number" system like
1
1.2
1.2.3
1.3
2
3
3.1
etc.
I want to parse an outline number and return the parent.
So for example...
parent("1.2.3.4") returns "1.2.3"
The only way I can figure is to
Scott David Daniels wrote:
> Felix Collins wrote:
>> I have an "outline number" system like
>> 1
>> 1.2
>> 1.2.3
>> I want to parse an outline number and return the parent.
>
> Seems to me regex is not the way to go:
> def parent(string):
> return string[: string.rindex('.')]
Absolute
Christopher Subich wrote:
> Scott David Daniels wrote:
Thanks to you both. Wow! what a quick response!
>string.rsplit('.',1)[0]
Clever Python! ;-)
Sorry, I mainly code in C so I'm not very Pythonic in my thinking.
Thanks again...
Felix
--
http://mail.python.org/mailman/listinfo/python-lis