Re: [Tutor] changing string in place

2009-01-10 Thread Paul McGuire
Sometimes pyparsing is less stressful than struggling with RE's typoglyphics, especially for a one-off conversion (also note handling of quoted strings - if a 'new Date(y,m,d)' occurs inside a quoted string, this script *won't* convert it): from pyparsing import nums,Word,Literal,quotedString # p

Re: [Tutor] changing string in place

2009-01-09 Thread Martin Walsh
Jon Crump wrote: > I'm still faced with the problem of the javascript months being 0 > indexed. I have to add 1 to group \2 in order to get my acurate > date-string. Obviously I can't do > > print jdate.sub(r'"\1-\2+1-\3"', s) > > because the first argument to sub() is a string. How can I act on \2

Re: [Tutor] changing string in place

2009-01-09 Thread Martin Walsh
Jon Crump wrote: > Dear all, > > I've been around and around with this and can't seem to conceptualize it > properly. > > I've got a javascript object in a text file that I'd like to treat as > json so that I can import it into a python program via > simplejson.loads(); however, it's not proper j

[Tutor] changing string in place

2009-01-09 Thread Jon Crump
Dear all, I've been around and around with this and can't seem to conceptualize it properly. I've got a javascript object in a text file that I'd like to treat as json so that I can import it into a python program via simplejson.loads(); however, it's not proper json because it has new Date(