How can I take integer regex?
Question: I'm trying to use regex in Python for taking some parts of a text. From a text
I need to take this kind of substring '2016-049172'. So what's the equivalent
regex? Thank you very much.

Here's a piece of code:

    
    
    import re
    
    pattern = re.compile(r"\s-\s[0-9]+[0-9]$]")
    my_string = 'Ticketing TSX - 2016-049172'
    
    matches = re.findall(pattern,my_string)
    print matches
    

Of course, my output is empty list. (I apologize for initial bad post, I'm
new)


Answer: The regex to use is this:

    
    
    \d{4}-\d{6}
    

Updating your example code, this will do it for you:

    
    
    import re
    
    pattern = re.compile(r"\d{4}-\d{6}")
    my_string = 'Ticketing TSX - 2016-049172'
    
    matches = re.findall(pattern,my_string)
    print matches
    

