problem with split

Sat Oct 7 07:27:41 CEST 2006

Think you need a regex like this: regex =

import re
test = re.compile(regex)

testing is done as follows:
res = test.match(mystring)
if res:
    number = # always a string consisting of decimals
    comment = # string starting with ; or None
it might be necessary to have the instr part of the regex as follows
[iI][nN][sS][tT][rR] to handle things like Instr or INSTR.

Hope this helps


On 6 Oct 2006 21:07:43 -0700, "Eric_Dexter at"
<Eric_Dexter at> wrote:

>apologies if I annoy and for spacing (google)
>def csdInstrumentList(from_file):
>    "Returns a list of .csd instruments and any comment lines after the
>    infile = open(from_file, 'r')
>    temp_number = 0
>    for line in infile:
>        if 'instr' in line:
>            s = re.split(r' +',line,3)
>            instr_number = s[1]
>    return instr_number
>I am coming pretty close to what I want with variations on theis but I
>cant seem to
>get 3 lines with the split and instr_number[array] = s[1] seems to give
>me an error.
>the data from the line I am trying to split in three would look like
>  instr 83     ;comment would be here
>I want comment returned in an array and instr_number returned in an

More information about the Python-list mailing list