Я уже получил совпавшую строку, используя регулярное выражение в python, как показано ниже.
import re
matches = re.finditer(r'<\S+?>',' Hi <a> This is </a> an example! ')
for match in matches:
print(
"matched string: '%s', start index: %s, end index: %s"
% (match.group(0), match.span(0)[0], match.span(0)[1])
)
результат:
matched string: '<a>', start index: 4, end index: 7
matched string: '</a>', start index: 16, end index: 20
теперь я хочу получить индекс оставшейся строки, что-то вроде:
[0,4],[7,16],[20,33]