@@ -82,23 +82,24 @@ time.sleep(SECONDS_IN_A_DAY)
8282** Bad:**
8383``` python
8484address= ' One Infinite Loop, Cupertino 95014'
85- city_zip_code_regex= r ' / ^ [^ , \\ ]+ [, \\ \s ]+ ( . +? ) \s * ( \d {5} ) ? $ / '
86- preg_match( $ cityZipCodeRegex, $ address, $ matches) ;
85+ city_zip_code_regex= ' ^[^,\\ ]+[,\\ \s]+(.+?)\s*(\d{5} )?$'
86+ matches = re.match(city_zip_code_regex, address)
8787
88- saveCityZipCode( $ matches[1 ],$ matches[2 ]);
88+ save_city_zip_code( matches[1 ], matches[2 ])
8989```
9090
9191** Not bad** :
9292
9393It's better, but we are still heavily dependent on regex.
9494
95- ``` php
96- $address = 'One Infinite Loop, Cupertino 95014';
97- $cityZipCodeRegex = '/^[^,\\]+[,\\\s]+(.+?)\s*(\d{5})?$/';
98- preg_match($cityZipCodeRegex, $address, $matches);
95+ ``` python
96+ address= ' One Infinite Loop, Cupertino 95014'
97+ city_zip_code_regex= ' ^[^,\\ ]+[,\\ \s]+(.+?)\s*(\d{5} )?$'
98+ matches= re.match(city_zip_code_regex, address)
99+
100+ city, zip_code= matches.groups()
99101
100- list(, $city, $zipCode) = $matches;
101- saveCityZipCode($city, $zipCode);
102+ save_city_zip_code(city, zip_code)
102103```
103104
104105** Good** :