Import Re String = " [.]% 16 days 11 Hello !! plate " Number = the re.findall (R & lt " \ D + " , String) # extract all integers Print ( ' all numbers: ' , Number) Number = Re. findAll (R & lt " (<= \ day) \ D +? " , String) # extract the designated alphanumeric Print ( ' the specified character: ' , number) number = the re.findall (R & lt " (\ D +) board " , String ) # extract digital pre-specified character Print ( ' pre-specified character:' , Number) # into digital Number = list (Map (int, Number)) # Put the transfer list numeric character Number Number = [0] # and then read list element Print ( ' into digital: ' , Number) # filtered English symbol string, kanji retention STE = the re.sub ( " [a-Za-Z0-9 \! \% \ [\] \, \.] " , "" , string) Print ( ' Character: ' , STE)
operation result:
All figures: [ '16', '11']
After the specified character: [ '11']
before the specified character: [ '11']
into digital: 11
characters: a top plate