Extracting the longest substring contain only numbers and letters, and begin with a letter, the print length of the character string and, if a plurality of the same length, to be printed out.

The python to test their level, T questions, 
TestStr = '.? # $% & Abc123 () * +, - / :; <= abc124> @ [4F] ^ {1aaa12 |}'
extracts contain only numbers and letters, and at the beginning of the longest substring of the alphabet, the length of the printed character string and, if a plurality of the same length, to be printed out. For example, the above extract the resulting string is:
abc123 6
abc124 6


above question is a python code

1. This is a big brother wrote: simple
import  re
lst = []
strnew = 'abc123$%&()*+,-./:;<=abc124>?@[4f]^{1aaa12|}'
find = re.findall('[a-zA-Z][a-zA-Z0-9]+',strnew)
for i in range(len(find)):
lst.append(len(find[i]))
maxlst = max(lst)

for j in range(len(find)):
if len(find[j]) == maxlst:
print(find[j],maxlst)


2.这也是一种

 

3. This is a stupid

 





Guess you like

Origin www.cnblogs.com/baozi888/p/11124540.html