Làm thế nào để bạn chọn một chữ cái trong một chuỗi trong python?

# Để lấy ba ký tự đầu tiên

Show

    # Để lấy tất cả các ký tự bắt đầu từ chỉ số 0

    # Để lấy tất cả các ký tự bắt đầu từ 0 đến chỉ số thứ 5

    # Để lấy tất cả các ký tự của chuỗi

    Đưa ra một chuỗi, nhiệm vụ là chỉ trích xuất các ký tự chữ cái từ một chuỗi. Đưa ra dưới đây là một số phương pháp để giải quyết vấn đề đã cho

    Phương pháp số 1. Sử dụng lại. tách ra

    Python3




    # Python code to demonstrate

    # to get characters from string

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    0
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    1

     

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    2

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    3
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    5

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    6_______0_______4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    8

     

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    9

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    2
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    3

     

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    4

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    5
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    7
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    8_______10_______9
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    7
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    8_______10_______9
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    6

     

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    7

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    ABGFDabcjw
    
    0
    ABGFDabcjw
    
    1_______30_______2
    ABGFDabcjw
    
    3

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    ABGFDabcjw
    
    6
    ABGFDabcjw
    
    1_______30_______2
    ABGFDabcjw
    
    9

    Đầu ra

    initial string :  123()#$ABGFDabcjw abceddfgh
    first string result:    A B G F D a b c j w 
    second string result:   a b c e d d f g h 
    

    Phương pháp #2. Sử dụng lại. tìm tất cả

    Python3




    # Python code to demonstrate

    ABGFDabcjw
    
    1

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    0
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    1

     

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    2

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    3
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    5

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    6_______0_______4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    8

     

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    9

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    ABGFDabcjw
    abceddfgh
    
    4_______54_______5
    ABGFDabcjw
    abceddfgh
    
    6
    ABGFDabcjw
    abceddfgh
    
    7

     

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    4

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    5
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    7
    ABGFDabcjw
    abceddfgh
    
    2_______54_______3
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    7_______54_______2_______54_______3
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    6

     

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    7

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    ABGFDabcjw
    
    0
    ABGFDabcjw
    
    1_______30_______2
    ABGFDabcjw
    
    3

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    ABGFDabcjw
    
    6
    ABGFDabcjw
    
    1_______30_______2
    ABGFDabcjw
    
    9

    Đầu ra

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    

    Phương pháp #3. Sử dụng isalpha()

    Python3




    # Python code to demonstrate

    # to get characters from string5

    # to get characters from string6

     

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    2

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    3
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    5

     

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    01

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0_______10_______1
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    2
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    05

     

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    4

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    5
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    09

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    10
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    11
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    12
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    13

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    14
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    15
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    16

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    17_______10_______5
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    20

     

     

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    7

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0_______10_______1
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    24
    ABGFDabcjw
    
    1
    ABGFDabcjw
    
    2
    ABGFDabcjw
    
    3

    Đầu ra

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    

    Phương pháp #4. Không có bất kỳ phương thức dựng sẵn nào

    Python3




    # Python code to demonstrate

    # to get characters from string5

    # to get characters from string6

     

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    2

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    3
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    5

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    35
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    37

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    38
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    40

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    41
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4_______0_______35
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    44
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    38

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    01

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    2
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    05

     

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    4

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    5
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    09

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    10
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    11
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    12
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    13

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    14
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    15
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    11
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    12
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    63

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    17_______10_______5
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    44
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    11

     

     

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    7

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    1
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    24
    ABGFDabcjw
    
    1
    ABGFDabcjw
    
    2
    ABGFDabcjw
    
    3

    Đầu ra

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    

    Phương pháp 5. Sử dụng phương pháp hiểu danh sách

    Python3




    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    3
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    5

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    41
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    81

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    82
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    84_______0_______10
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    11
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    12
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    3
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    15
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    11
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    12
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    92

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0_______0_______94

    Đầu ra

    ABGFDabcjw
    

    Phương pháp 6. Sử dụng hàm liệt kê

    Python3




    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    3
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    5

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    41
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    81

    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    82
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    4
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    03
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    10
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    05
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    12
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    07
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    08
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    15
    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    10
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    12
    initial string : 
     123()#$ABGFDabcjw 
     abceddfgh
    first string result:  ABGFDabcjw
    second string result:  abceddfgh
    
    92

    initial string :  123()#$ABGFDabcjw
    first result:  ABGFDabcjw
    
    0_______0_______94

    Đầu ra

    ABGFDabcjw
    

    Phương pháp số 7. Sử dụng bộ lọc và lambda

    Hàm bộ lọc lấy một hàm và một đối tượng dạng danh sách làm đầu vào và trả về một danh sách các phần tử từ đối tượng đầu vào mà hàm trả về True. Trong trường hợp này, hàm là lambda x. x. isalpha(), trả về True cho bất kỳ ký tự chữ cái nào và Sai cho bất kỳ ký tự không phải chữ cái nào. Phương thức nối sau đó được sử dụng để nối các ký tự thành một chuỗi