Jul-24-2022, 08:32 PM
(Jul-24-2022, 06:36 PM)rob101 Wrote: I think I may have cracked this for you. If not, then I'm sure you can make any adjustments. If not, then I'm more than happy to help you.
Try it by coding in your text.
#!/usr/bin/python3 import re def fdigit(d): digit = re.search('\d',d) if digit: lst_string = re.split('\d',d) return lst_string[-1] string = "" # put your text in this string object lst_string = string.split(' ') pstring = '' for get_word in range(len(lst_string)): word = lst_string[get_word] check = fdigit(word) if not check: pstring += word+' ' else: pstring += check+' ' print(pstring)I'm not 100% happy with my function name, now that it's doing a slightly different job to the one that it was conceived for, but it'll do.
{edit}
I Think we posted at almost the same time there. If this is any use to you, then cool; if not, maybe someone else can learn something from it.
Quote:I see. thanks for the information and help Unfortunately I will not be able to modify it to suit however I appreciate what you have done. may I ask help with the existing code posted? Thanks