a simple string question

vedrandekovic at v-programs.com vedrandekovic at v-programs.com
Fri Jul 27 19:46:46 CEST 2007


On 27 srp, 19:29, Wildemar Wildenburger <wilde... at freakmail.de> wrote:
> vedrandeko... at v-programs.com wrote:
> > I have one question about string.I am trying to make an function to
> > analyze line  of some text, this is my example: "HELLO;HELLO2:WORLD:",
> >  if that function in this text find ";" and ":" ( in this example will
> > find both)
>
> > e.g  that function must return this:
>
> > "HELLO;\nHELLO2:\n\t\t\t\t\t\t\tWORLD:"
>
> If I understand you correctly you want to replace ";" by ";\n" and ":"
> by ":\n\t\t\t\t\t\t\t".
> Well guess what? The replace() method does just this. Have a read:
> <URL:http://docs.python.org/lib/string-methods.html>
>
> /W

Hello,

No,that's not what I need...
When this function detect ";" or ":" ,it must append character "\n" or
"\n\t" ahead ":" or ";" another e.g

1) text="Hello world;Hello:Hello2"

2) When function detect ";" or ":" it must append character "\n" or "\n
\t" ahead ":" or ";", so that must look like this:

NEW TEXT :  "Hello world;\nHello:\n\t\t\n\n\n\n\n\nHello2"

Regards,
Vedran




More information about the Python-list mailing list