I have written a code to find the substring from a string. It prints all substrings. But I want a substring that ranges from length 2 to 6 and print the substring of minimum length. Please help me
Program:
import re
p=re.compile('S(.+?)N')
s='ASDFANSAAAAAFGNDASMPRKYN'
s1=p.findall(s)
print s1
output:
['DFA', 'AAAAAFG', 'MPRKY']
Desired output:
'DFA' length=3