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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -