I want to get boolean for all strings having digits at the end of string. For example
import re
# list of strings
li = ['/Usein-kysytyt-kysymykset;jsessionid=0727CD5A45A05D3CBD5A26D459C34D9D.xxlapp11',
'/vaatteet/naisten-vaatteet/naisten-takit/c/120204',
'/pyoraily/pyorailyvarusteet/pyorankuljetuslaukut-ja-vannepussit/c/100818_8']
for i in li:
if(bool(re.match('\d+$', i))):
print(i)
So this should work and return me True for li[1] and li[2] and False for li[0] but it is returning false for all elements in the list. What is wrong here ?
re.matchonly matches at the beginning of a string. Usere.searchinstead!re.matchshould do the trick, but inliI see that all strings end with digits so it should return all of them.li[0]to be True also since it ends with11?