May-14-2020, 01:23 PM
Hi,
I have below code to print matching start index and end index with aligned columns.
I use below code:
import re
pattern = re.compile('ab')
My output is below:
but my desired output in 3rd line the columns are not aligned after 10:
I have below code to print matching start index and end index with aligned columns.
I use below code:
import re
pattern = re.compile('ab')
1 2 3 4 |
matcher = pattern.finditer( 'zxaababaababa' ) for match in matcher: print ( "starting index " , str (match.start()) + " End index " , str (match.end())) #print("The matched endstarting index is: ", match.end()) |
1 2 3 4 |
starting index 3 End index 5 starting index 5 End index 7 starting index 8 End index 10 starting index 10 End index 12 |
1 2 3 4 |
starting index 3 End index 5 starting index 5 End index 7 starting index 8 End index 10 starting index 10 End index 12 |