Find the index of the first digit in a string

前端 未结 14 829
清酒与你
清酒与你 2020-12-28 12:29

I have a string like

\"xdtwkeltjwlkejt7wthwk89lk\"

how can I get the index of the first digit in the string?

14条回答
  •  时光取名叫无心
    2020-12-28 12:34

    import re
    result = "  Total files:...................     90"
    match = re.match(r".*[^\d](\d+)$", result)
    if match:
        print(match.group(1))
    

    will output

    90
    

提交回复
热议问题