Kunal Jamdade writes: > There is a filename say:- 'first-324-True-rms-kjhg-Meterc639.html' . > > I want to extract the last 4 characters. I tried different regex. but > i am not getting it right. > > Can anyone suggest me how should i proceed.?
os.path.splitext(name) # most likely; also: os.path.split, os.path.join name.rsplit('.', 1) # might do name[-4:] # "last 4 characters" name.endswith('.html') # is this what you really want? This is not a regex job. -- https://mail.python.org/mailman/listinfo/python-list