Replcae inner space in Python -
iam new python, , need remove space between string , digit not between 2 strings.
eg:
input : paragraph 25 in documents , paragraph number in file.
output : paragraph25 in documents , paragraph number in file.
how can done in python ? tried regex
re.sub("paragraph\s[a-z]", "paragraph[a-z]", input)
but not working.
>>> re.sub(r'\s+(\d+)', r'\1', 'program 25 fun') 'program25 fun'
that might work in pinch. i'm not familiar regexes, can chime in more robust.
basically match on whitespace succeeded numbers , remove it.
Comments
Post a Comment