Re: String splitting with exceptions

2013-08-29 Thread wxjmfauth
Le mercredi 28 août 2013 18:44:53 UTC+2, John Levine a écrit : > I have a crufty old DNS provisioning system that I'm rewriting and I > > hope improving in python. (It's based on tinydns if you know what > > that is.) > > > > The record formats are, in the worst case, like this: > > > > fo

Re: String splitting with exceptions

2013-08-28 Thread John Levine
>Can you have brackets within brackets? If so, this is impossible to deal >with within a regex. Nope. It's a regular language, not a CFL. >Otherwise: re.findall('((?:[^[:]|\[[^]]*\])*):?',s) >['foo.[DOM]', '', '[IP6::4361:6368:6574]', '600', '', ''] That seems to do it, thanks. -- Regard

Re: String splitting with exceptions

2013-08-28 Thread Peter Otten
Neil Cerutti wrote: > On 2013-08-28, John Levine wrote: >> I have a crufty old DNS provisioning system that I'm rewriting and I >> hope improving in python. (It's based on tinydns if you know what >> that is.) >> >> The record formats are, in the worst case, like this: >> >> foo.[DOM]::[IP6::436

Re: String splitting with exceptions

2013-08-28 Thread Neil Cerutti
On 2013-08-28, Tim Chase wrote: > On 2013-08-28 13:14, random...@fastmail.us wrote: >> On Wed, Aug 28, 2013, at 12:44, John Levine wrote: >> > I have a crufty old DNS provisioning system that I'm rewriting >> > and I hope improving in python. (It's based on tinydns if you >> > know what that is.)

Re: String splitting with exceptions

2013-08-28 Thread Neil Cerutti
On 2013-08-28, John Levine wrote: > I have a crufty old DNS provisioning system that I'm rewriting and I > hope improving in python. (It's based on tinydns if you know what > that is.) > > The record formats are, in the worst case, like this: > > foo.[DOM]::[IP6::4361:6368:6574]:600:: > > What I

Re: String splitting with exceptions

2013-08-28 Thread Tim Chase
On 2013-08-28 13:14, random...@fastmail.us wrote: > On Wed, Aug 28, 2013, at 12:44, John Levine wrote: > > I have a crufty old DNS provisioning system that I'm rewriting > > and I hope improving in python. (It's based on tinydns if you > > know what that is.) > > > > The record formats are, in th

Re: String splitting with exceptions

2013-08-28 Thread random832
On Wed, Aug 28, 2013, at 12:44, John Levine wrote: > I have a crufty old DNS provisioning system that I'm rewriting and I > hope improving in python. (It's based on tinydns if you know what > that is.) > > The record formats are, in the worst case, like this: > > foo.[DOM]::[IP6::4361:6368:6574]

Re: String splitting with exceptions

2013-08-28 Thread Skip Montanaro
> The record formats are, in the worst case, like this: > > foo.[DOM]::[IP6::4361:6368:6574]:600:: > Any suggestions? Write a little parser that can handle the record format? Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: String splitting by spaces question

2011-11-23 Thread DevPlayer
This is an 'example string' Don't for get to watch for things like: Don't, Can't, Won't, I'll, He'll, Hor'davors, Mc'Kinly -- http://mail.python.org/mailman/listinfo/python-list

Re: String splitting by spaces question

2011-11-23 Thread Phil Rist
In article <3f19e4c0-e010-4cb2-9f71-dd09e0d3c...@r9g2000vbw.googlegroups.com>, Massi says... > >Hi everyone, > >I have to parse a string and splitting it by spaces. The problem is >that the string can include substrings comprises by quotations which >must mantain the spaces. What I need is to pass

Re: String splitting by spaces question

2011-11-23 Thread Miki Tebeka
http://docs.python.org/library/shlex.html -- http://mail.python.org/mailman/listinfo/python-list

Re: String splitting by spaces question

2011-11-23 Thread Jerry Hill
On Wed, Nov 23, 2011 at 12:10 PM, Massi wrote: > Hi everyone, > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces. What I need is to pass from a string like: > > This is an 'exampl

Re: String splitting by spaces question

2011-11-23 Thread Nick Dokos
Alemu Tadesse wrote: > Can we use rsplit function on an array or vector of strings ? it works > for one not for vector > ... > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces.

Re: String splitting by spaces question

2011-11-23 Thread Arnaud Delobelle
On 23 November 2011 17:10, Massi wrote: > Hi everyone, > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces. What I need is to pass from a string like: > > This is an 'example string

RE: String splitting by spaces question

2011-11-23 Thread Alemu Tadesse
Hi Everyone, Can we use rsplit function on an array or vector of strings ? it works for one not for vector Alemu -Original Message- From: python-list-bounces+atadesse=sunedison@python.org [mailto:python-list-bounces+atadesse=sunedison@python.org] On Behalf Of Massi Sent: Wednes

Re: string splitting

2006-10-17 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Hello, > I have thousands of files that look something like this: > > wisconsin_state.txt > french_guiana_district.txt > central_african_republic_province.txt > > I need to extract the string between the *last* underscore and the > extention. > So based on the files abov

Re: string splitting

2006-10-17 Thread stefaan
> Anyone have any ideas? l = "wisconsin_state.txt" l.split(".")[0].split("_")[-1] Explanation: --- the split(".")[0] part takes everything before the "." the split("_")[-1] part selects in the last element in the list of substrings which are separated by "_" -- http://mail.pyth

Re: string splitting

2006-10-16 Thread bearophileHUGS
A pair of solutions: >>> s = "central_african_republic_province.txt" >>> s.rsplit("_", 1)[-1].split(".")[0] 'province' >>> import re >>> p = re.compile(r"_ ([^_]+) \.", re.VERBOSE) >>> s = """\ ... wisconsin_state.txt ... french_guiana_district.txt ... central_african_republic_province.txt""" >>>

Re: string splitting

2006-10-16 Thread rdharles
Much thanks for your replies hiaips & Simon! R.D. -- http://mail.python.org/mailman/listinfo/python-list

Re: string splitting

2006-10-16 Thread hiaips
[EMAIL PROTECTED] wrote: > Hello, > I have thousands of files that look something like this: > > wisconsin_state.txt > french_guiana_district.txt > central_african_republic_province.txt > > I need to extract the string between the *last* underscore and the > extention. > So based on the files abov

Re: string splitting

2006-10-16 Thread Simon Brunning
On 16 Oct 2006 12:12:38 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello, > I have thousands of files that look something like this: > > wisconsin_state.txt > french_guiana_district.txt > central_african_republic_province.txt > > I need to extract the string between the *last* underscore