Python Regex Extract

December 22, 2018

Extract trailing number from string.

user = 'ABC1234'
m = re.search(r'^[a-zA-Z]+(\d+)$', user)
if m:
    user_number = m.group(1)
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.