I have two examples of pair of strings
YHFLSPYVY # answer
LSPYVYSPR # prediction
+++******ooo
YHFLSPYVS # answer
VEYHFLSPY # prediction
oo*******++
As stated above I'd like to find the overlapping region (*
) and non-overlapping region in answer (+
) and prediction (o
).
How can I do it in Python?
I'm stuck with this
import re
# This is of example 1
ans = "YHFLSPYVY"
pred= "LSPYVYSPR"
matches = re.finditer(r'(?=(%s))' % re.escape(pred), ans)
print [m.start(1) for m in matches]
#[]
The answer I hope to get for example 1 is:
plus_len = 3
star_len = 6
ooo_len = 3