Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87378
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fdn.fr!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:help': 0.08; 'messing': 0.09; 'trailing': 0.09; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'search:': 0.16; 'string)': 0.16; 'zeros': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; "haven't": 0.24; "i've": 0.25; 'this:': 0.26; 'header:In-Reply- To:1': 0.27; 'leave': 0.29; 'decimal': 0.31; 'larry': 0.31; 'this.': 0.32; 'figure': 0.32; "can't": 0.35; 'but': 0.35; 'example,': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'remove': 0.60; 'negative': 0.60 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=CYWG5dbl c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=mlFM_a_ONtUA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=lS_nbFXH5iBv918KsuIA:9 a=QEXdDO2ut3YA:10 |
| X-AUTH | mrabarnett@:2500 |
| Date | Fri, 13 Mar 2015 17:29:36 +0000 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: regex help |
| References | <CACwCsY6cN6+mZVYWnMpKGsXg6jd7Y8Gav9DC7HkXcPtU-pDXDw@mail.gmail.com> |
| In-Reply-To | <CACwCsY6cN6+mZVYWnMpKGsXg6jd7Y8Gav9DC7HkXcPtU-pDXDw@mail.gmail.com> |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.333.1426267966.21433.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1426267966 news.xs4all.nl 2937 [2001:888:2000:d::a6]:57919 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:87378 |
Show key headers only | View raw
On 2015-03-13 16:05, Larry Martell wrote: > I need to remove all trailing zeros to the right of the decimal point, > but leave one zero if it's whole number. For example, if I have this: > > 14S,5.0000000000000000,4.56862745000000,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.137254901960000 > > I want to end up with: > > 14S,5.0,4.56862745,3.7272727272727271,3.394736842105263,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196 > > I have a regex to remove the zeros: > > '0+[,$]', '' > > But I can't figure out how to get the 5.0000000000000000 to be 5.0. > I've been messing with the negative lookbehind, but I haven't found > one that works for this. > Search: (\.\d+?)0+\b Replace: \1 which is: re.sub(r'(\.\d+?)0+\b', r'\1', string)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: regex help MRAB <python@mrabarnett.plus.com> - 2015-03-13 17:29 +0000
csiph-web