AnsweredAssumed Answered

Using Regular Expression in Calculate Field

Question asked by Matt_C_Smith on Apr 22, 2020
Latest reply on Apr 23, 2020 by bixb0012

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...




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.