Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53510
| References | <5224B786.2050606@gmail.com> |
|---|---|
| Date | 2013-09-02 19:18 +0200 |
| Subject | Re: How can I remove the first line of a multi-line string? |
| From | Vlastimil Brom <vlastimil.brom@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.504.1378142319.19984.python-list@python.org> (permalink) |
2013/9/2 Anthony Papillion <papillion@gmail.com>: > Hello Everyone, > > I have a multi-line string and I need to remove the very first line from > it. How can I do that? I looked at StringIO but I can't seem to figure > out how to properly use it to remove the first line. Basically, I want > to toss the first line but keep everything else. Can anyone put me on > the right path? I know it is probably easy but I'm still learning Python > and don't have all the string functions down yet. > > Thanks, > Anthony > -- > http://mail.python.org/mailman/listinfo/python-list Hi, it is probably not worth it for such simple replacement, but just to add another possibility to the already mentioned methods - you can use regular expression replacement: >>> import re >>> re.sub(r"^.*\n", "", "abc\ndef\nghi") 'def\nghi' >>> hth, vbr
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How can I remove the first line of a multi-line string? Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-09-02 19:18 +0200
csiph-web