Asking for some help on a task I'm dealing with.
I have a field (PLAN) with a string that I'd like to split into two separate text fields (PLAN_PFX & PLAN_NUM). Each entry is predictable in the sense that it will be 1-5 alphabetic characters followed by 1-6 numeric characters. Alphabetic characters are always upper-case.
So what I need to do is something like...
| PLAN | PLAN_PFX | PLAN_NUM |
|---|
| A305 | A | 305 |
| BTR86542 | BTR | 86542 |
| RP808112 | RP | 808112 |
| WR8 | WR | 8 |
I know I'm going to need to use Regular Expression for it. I've tried a few methods just focusing on calculating for PLAN_NUM initially but I'm just fumbling around in the dark really.
PLAN_NUM = regex(!PLAN!)
import re
def regex(text):
split_list = re.split(r'[A-Z]', text)
return split_list[-1]
But this just returns a blank entry.
Any help appreciated. Thanks in advance.