fork download
  1. import re
  2. str0 = '10.1002/0470868279-ch1'
  3. print(re.sub(r'\W+\w+$','',str0))
  4. print(re.sub(r'\W+\w+$','','10.1002/0470868279.1'))
  5. print(re.sub(r'\W+\w+$','','10.1002/0470868279.ch1'))
  6. print(re.sub(r'\W+\w+$','','10.1002/0470868279.c'))
  7. print(re.sub(r'\W+\w+$','','h1'))
  8.  
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
10.1002/0470868279
10.1002/0470868279
10.1002/0470868279
10.1002/0470868279
h1