Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83756
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: what would be the regular expression for null byte present in a string |
| Date | 2015-01-14 15:11 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <2003101.I8trXTtxXO@PointedEars.de> (permalink) |
| References | <39F9E8A5546B9448A82E55FBEBE3EC450BD029A5@SACMBXIP03.sdcorp.global.sandisk.com> <mailman.17677.1421160126.18130.python-list@python.org> <13414923.1GtqDO6yAl@PointedEars.de> |
Thomas 'PointedEars' Lahn wrote: > Peter Otten wrote: >> Shambhu Rajak wrote: >>> I want to find a re pattern that could replace all the \x01..\x0z to be >>> replace by empty string '', so that I can get the desired portion of >>> string >>> >>> Can anyone help me with a working regex for it. >> >> I think you want the str.tranlate() method rather than a regex. > > Another possibility, but given the length of the list probably not the > most efficient one. Aside from re and this one, here is another (tested > with Python 3.4.2): > > filtered = ''.join(filter(lambda ch: ord(ch) > 0x0f, s)) filtered = ''.join(filter(lambda ch: ch > "\x0f", s)) -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: what would be the regular expression for null byte present in a string Peter Otten <__peter__@web.de> - 2015-01-13 15:41 +0100
Re: what would be the regular expression for null byte present in a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-14 14:52 +0100
Re: what would be the regular expression for null byte present in a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-14 15:11 +0100
csiph-web