Match : Match only once, the
start match does not go up, then does not continue matching a,b,\w+Match (A, "abcdef") matches a>>> Re.match ("A", "abcdef"). Group () ' A ' match (b, "abcdef") >>> print Re.match ("b "," abcdef ") Nonematch (" \w+ "," abcdef ")search, full string match, but match only once, match does not continue to match a, b,\w+>>> Re.search ("A", "ABCDEF ABC 123 456"). Group () ' A ' >>> re.search ("B", "ABCDEF ABC 123 456"). Group () ' B ' >>> re.search ("\w+", "abcdef ABC 123 456"). Group () ' ABCdef 'FindAllNote: findall return list, List cannot group ()>>> Print Re.findall (r "B", "ABCDEF ABC 123 456") [' B ', ' B '] >>> print Re.findall (r "a", "ABCDEF ABC 123 456") ) [' A ', ' a '] >>> print Re.findall (r "\w+", "abcdef ABC 123 456") [' abcdef ', ' abc ', ' 123 ', ' 456 ']
Python regular Match search FindAll