Python Regular Expression for SIP URI variables?
问题 I am using this regular expression for SIP (Session Initiation Protocol) URIs to extract the different internal variables. _syntax = re.compile('^(?P<scheme>[a-zA-Z][a-zA-Z0-9\+\-\.]*):' # scheme + '(?:(?:(?P<user>[a-zA-Z0-9\-\_\.\!\~\*\'\(\)&=\+\$,;\?\/\%]+)' # user + '(?::(?P<password>[^:@;\?]+))?)@)?' # password + '(?:(?:(?P<host>[^;\?:]*)(?::(?P<port>[\d]+))?))' # host, port + '(?:;(?P<params>[^\?]*))?' # parameters + '(?:\?(?P<headers>.*))?$') # headers m = URI._syntax.match(value) if m: