On Jul 27, 8:23 am, [EMAIL PROTECTED] wrote: > Hello, > > 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:" > > Regards, > Vedran
You can use split twice print text.split( ":" ) and then split the returned list items on ";". You could also use text.find( ":" ), but that would be pretty much the same thing only harder. Also, you can step through the string one character at a time and compare each character. Finally, you can use an re, (regular expression), but if you are still learning how to parse strings, I don't think you want to get into re's. -- http://mail.python.org/mailman/listinfo/python-list