Is this what you are after? *>>> *data = 'first-324-True-rms-kjhg-Meterc639.html'
*>>> *extension = data.find('.html') *>>> *extension 33 *>>> *data[extension-4:extension] 'c639' On 26 July 2017 at 13:00, Johann Spies <johann.sp...@gmail.com> wrote: > On 26 July 2017 at 13:52, Kunal Jamdade <kunal123jamd...@gmail.com> wrote: > > 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.? > > What have you tried? > > Why do you need regular expression? > > >>> s = 'first-324-True-rms-kjhg-Meterc639.html' > > >>> s[-4:] > 'html' > > Regards > Johann > -- > Because experiencing your loyal love is better than life itself, > my lips will praise you. (Psalm 63:3) > -- > https://mail.python.org/mailman/listinfo/python-list > -- Paul Barry, t: @barrypj <https://twitter.com/barrypj> - w: http://paulbarry.itcarlow.ie - e: paul.ba...@itcarlow.ie Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland. -- https://mail.python.org/mailman/listinfo/python-list