s = 'webs-pub-subscription-billme-clients-api-3.0.14.1.war'
# slice between the last dash, and the last dot:
print s[s.rfind('-')+1:s.rfind('.')]
# or, regex split on the last dash or the last dot
# (a dash not followed by another dash, or a dot not followed by another dot)
# and take the middle chunk
import re
print re.split('-(?!.*-)|\.(?!.*\.)', s)[1]
就这样好了:
Try online at Repl.it
相关问题 更多 >
编程相关推荐