Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ 'SW', '1', 'A', ' ', '1', 'AA' ]
- [ 'SW', '1', 'A' ]
- [ 'SW', '22', ' ', '3' ]
- $strs = ["SW1A 1AA", "SW1A", "SW22 3"];
- foreach ($strs as $s) {
- if (preg_match_all('~[a-zA-Z]+|d+|[^da-zA-Z]+~', $s, $chunks)) {
- print_r($chunks[0]);
- }
- }
- // - Array ( [0] => SW [1] => 1 [2] => A [3] => [4] => 1 [5] => AA )
- // - Array ( [0] => SW [1] => 1 [2] => A )
- // - Array ( [0] => SW [1] => 22[2] => [3] => 3 )
- [a-zA-Z]+|d+|[^da-zA-Z]+
Add Comment
Please, Sign In to add comment