Hi;

If I have a srt file (lines in similar format given below).

42
00:02:21,085 --> 00:02:22,709
Just tell Cuddy you've 
got an urgent case.

43
00:02:22,709 --> 00:02:24,680
- You had to leave early.
- That would be lying.

44
00:02:24,680 --> 00:02:26,119
And that would be wrong.

I would like to know if there is some possible way to distinguish between numeric and characters so that we can compare all digits (0-9) and words (a-z,A-Z).

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Like this, using string methods that can be applied on a line-by-line basis:

>>> '42'.isdigit()
True
>>> 'Test'.isdigit()
False
>>>

Hi JLM

The mentioned code will only do for a sinlge line matching whereas I want to compare thousands of lines in a file which start with different numeric combination and alphabets combination and want to extract lines with only alphabets.
Is there some possible way out? Lik could you compare all digits '0,1,2,3,4,5,6,7,8,9' 'a,b,c,...,z; and do extraction on this base.

I provided an answer to the question that you asked, which was

I would like to know if there is some possible way to distinguish between numeric and characters

Now it is up to you to take that principal and implement it in a simple loop to finish this task. We're not here to create custom solutions for you, we simply help when you get stuck and teach you how to teach yourself to program. Please read the site policies and forum guidelines, as well as all posted announcements before posting.

It would also help if you tried searching to see if other people have already had the same question answered (HINT: they have).

Comments
good point
This article has been dead for over six months. Start a new discussion instead.