I am trying to extract text between two iterators. I have tried using span() function on it to find the start and the end span How do I proceed further, to extract text between these spans
start_matches = start_pattern.finditer(filter_lines)
end_matches = end_pattern.finditer(filter_lines)
for s_match in start_matches :
s_cargo=s_match.span()
for e_match in end_matches :
e_cargo=e_match.span()
Using the span: 1) s_cargo and 2) e_cargo, I would want to find the text within the string filter_lines
I am relatively new to python, any kind of help is much appreciated.
you can try:
my_data = []
for s, e in zip(s_cargo, e_cargo):
start, _ = s
_, end = e
my_data.append(your_text[start: end])
variable your_text
should be the text over whom you are filtering using regex
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.