How do I cut out a piece of text?

Emile van Sebille emile at fenx.com
Thu Sep 14 11:09:20 EDT 2000


After reading the file contents into a variable, split
it into fragments using string.split(txt,"\n  DEF").
Then pick the piece you want to copy, replace the "DEF"
and write it to the file.

HTH,


PS This works well if the text you're working with is
as highly consistent as your example.

--

Emile van Sebille
emile at fenx.com
-------------------


"Fredrik Lundin" <m94lufr at mtek.chalmers.se> wrote in message
news:8pq0kg$d20$1 at nyheter.chalmers.se...
> Hey!
>
> I want to cut out a piece of text and put it in a new
file.
> Lets say that the text looks like this (VRML transform
nodes):
>
>   DEF faceA Transform {
>    children Shape {
>     appearance Appearance { material USE Testobjekt_0 }
>     geometry USE faceA_0Geo
>    }
>   }
>   DEF faceB Transform {
>    children Shape {
>     appearance Appearance { material USE Testobjekt_0 }
>     geometry USE faceB_0Geo
>    }
>   }
>   DEF faceC Transform {
>    children Shape {
>     appearance Appearance { material USE Testobjekt_0 }
>     geometry USE faceC_0Geo
>    }
>   }
>
> I would like to put this plart into a new file:
>
>   DEF faceB Transform {
>    children Shape {
>     appearance Appearance { material USE Testobjekt_0 }
>     geometry USE faceB_0Geo
>    }
>   }
>
> Could someone help me with this?
> I have tried quite alot to accomplish it, but I can't seem
to eliminate the
> stuff ahead of the wanted text portion.
>
> /Fred
>
>





More information about the Python-list mailing list