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
>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
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
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.)
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
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
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]
> 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
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
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
http://docs.python.org/library/shlex.html
--
http://mail.python.org/mailman/listinfo/python-list
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
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.
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
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
[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
> 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
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"""
>>>
Much thanks for your replies hiaips & Simon!
R.D.
--
http://mail.python.org/mailman/listinfo/python-list
[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
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
21 matches
Mail list logo