0

以下のようなアイテムのリストがあります

list1=['test_input_1','test_input_2','test_input_3','test_input_10','test_input_11']

次の出力が必要です- test_input_1

コード

for each in list1:
    string1 = each
    pattern = r'test_.*[1].*'
    match = re.search(pattern,string1)
    if match:
        print 'matched=', match.group()

Output-
matched= test_input_1
matched= test_input_10
matched= test_input_11

Expected Output-
matched= test_input_1

また、パターンの前の「r」と「u」の違いは何ですか?

4

1 に答える 1