remove special characters from line

Chris Rennert Chris.Rennert at mdi-oshkosh.com
Tue Jul 1 12:15:43 EDT 2003


Thanks guys for the help,

As I was waiting for a reply I was trying a few things as well, this is what
I ended up doing.
I created a   list with all the valid characters in in and just did a index
check if(line[0] in LIST):
That seemed to do  exactly what I wanted.
Again I thank you for the constructive replies Radovan & Alan.

Chris Rennert
"Alan Kennedy" <alanmk at hotmail.com> wrote in message
news:3F01AECF.965FAADA at hotmail.com...
> [Chris Rennert]
>
> > If I have a line like this
> >
> > ²blah blah blah blah blah
> >
> > I know I could do a slice like this [1:] to pull everything but the
> > special character, but what if I have several lines in a file.
> > I am not sure how I would detect a special character like that.  I
> > would just like to pull everything from those lines (and the special
> > character always appears as the first character, but not on every line)
> > except for the special characters.
>
> How about something like this?
>
> for line in file('myfile.stars'):
>     print line.lstrip('*')
>
> Should remove all '*' (even if there is more than one) from the beginnings
(but
> not the ends) of lines.
>
> Egor Bolonev wrote:
>
> > I didn't get what you're talkink about.
>
> Then what was the purpose of your reply?
>
> I find it helps keeps the signal noise to ratio of the group down if
people only
> post when they have something to contribute.
>
> regards,
>
> -- 
> alan kennedy
> -----------------------------------------------------
> check http headers here: http://xhaus.com/headers
> email alan:              http://xhaus.com/mailto/alan






More information about the Python-list mailing list