Regular expression

Andre Müller gbs.deadeye at gmail.com
Wed Jul 26 08:09:45 EDT 2017


fname = 'first-324-True-rms-kjhg-Meterc639.html'

# with string manipulation
stem, suffix = fname.rsplit('.', 1)
print(stem[-4:])

# oo-style with str manipulation
import pathlib
path = pathlib.Path(fname)
print(path.stem[-4:])



More information about the Python-list mailing list