Python: Regex

From RHS Wiki
Revision as of 08:00, 24 October 2018 by Rafahsolis (talk | contribs)
Jump to navigation Jump to search

Port

port_regex = re.compile(r'\b('
                        r'6553[0-5]|'
                        r'655[0-2][0-9]|'
                        r'65[0-4][0-9][0-9]|'
                        r'6[0-4][0-9][0-9][0-9]|'
                        r'[1-5][0-9][0-9][0-9][0-9]|'
                        r'[1-9][0-9][0-9][0-9]|'
                        r'[1-9][0-9][0-9]|'
                        r'[1-9][0-9]|'
                        r'[1-9])'
                        r'\b')

IP

ip = re.compile('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')