NewB question on text manipulation

ProvoWallis gshepherd281281 at
Wed May 3 07:37:04 CEST 2006

I'm totally stumped by this problem so I'm hoping someone can give me a
little advice or point me in the right direction.

I have a file that looks like this:

<SC>APPEAL<XC>40-24; 40-46; 42-46; 42-48; 42-62; 42-63 <SC>PROC

(i.e., <<SC>[chapter name]<XC>[multiple or single book page
ranges]<SC>[chapter name]<XC>[multiple or single book page

but I want to change it so that it looks like this

<1><SC>PROC GUIDE<XC>92<LT>1(b)(1)

but I'm not at all sure how to do it.

I've come up with a simlple function that will change the order of the
text but I'm not sure how to break out

     def Switch(m):

          return '%s<LT>%s' % (,

     data = re.sub(r'''<1>(.*?)<LT>(.*?)\n''', Switch, data)

But I'm still a long way from what I need.

Any pointers would be greatly appreciated.



More information about the Python-list mailing list