jeudi 16 avril 2015

How to find 6 digits in a string in python?


Vote count:

0




An example string is CPLR_DUK10_772989_2. I want to pick out "772989" specifically. I would imagine using re.findall is a good way to go about it, however, I don't have a very good grasp on regular expression so I find myself stumped on this one.


Here is a sample of code that I thought would work, until I looked at the full list of strings, and saw that it definitely doesn't. I suppose I'm looking for some more robustness!



for ad in Ads:
num = ''.join(re.findall(numbers,ad)[1:7])
ID.append(num)
ID = pd.Series(ID)


Thank you for any help!



asked 22 secs ago

bpr

21






How to find 6 digits in a string in python?

Aucun commentaire:

Enregistrer un commentaire