Correctly splitting a string into an array : Python regex split() vs findall() -
i seem seeing differences in assumed same thing. attempting separate string array of regex matches. when try split believed should have, incorrectly array of empty strings following
>>> re.split(a, tosplit) ['', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '']
however, when run findall correctly of matches such
>>> matches in re.findall(a, tosplit): ... print(matches) 0b945c19de6c4857f51ec80057f5d0b79e25d56f48605b6ebf0665d455f2cb48 334892954139-cloudwatchlogsapigateway-global-us-east-1 [08/jul/2016:11:54:09 +0000] 54.237.227.51 ... etc.
what functional difference between findall , split, , should doing use regex split string array.
Comments
Post a Comment