>>> import re >>> pat_obj=re.compile('[0-9,]+') >>> str='foo 4,566 bar 1,234' >>> >>> text=pat_obj.findall(str) >>> for num in text: ... str=str.replace(num,num.replace(',','').rjust(len(num),' ')) ... >>> str 'foo 4566 bar 1234'
reformatting text with comma separated numbers
reformatting text with comma separated numbers
|
|
Messages In This Thread |
reformatting text with comma separated numbers - by Skaperen - May-06-2020, 06:22 AM
RE: reformatting text with comma separated numbers - by anbu23 - May-06-2020, 08:09 AM
RE: reformatting text with comma separated numbers - by Skaperen - May-06-2020, 08:21 PM
RE: reformatting text with comma separated numbers - by DeaD_EyE - May-06-2020, 08:46 AM
RE: reformatting text with comma separated numbers - by anbu23 - May-07-2020, 06:14 AM
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
sorting with numbers in text | Skaperen | 5 | 3,793 |
Jul-20-2021, 01:15 AM Last Post: Skaperen |
Users browsing this thread: 2 Guest(s)