regex - How do I have the index of an item in a python list which exactly matches a given regular expression pattern? -


suppose have list of string items following:

lst = ['apple', 'mango', 'mime'] p = r"mime" # regex pattern 

now, want have index of item matches pattern p. clearly, answer 2. how do it?

here code re module regular expressions

import re lst = ['apple', 'mango', 'mime'] p = r"mime" # regex pattern in range(0,len(lst)):     if re.compile(p).match(lst[i]):          print 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -