I'm beginner in ArcGIS Pro (I just switched from QGIS) and have some problem with some a little more advanced operation in field calculator. I would like to know how to use REGEX in field calculator to extract particular part of the string.
The string if in "Adr_for" field and in field "Number" I want to have extracted part.
Examples of the strings in "Adr_for":
13-0222222-1-02226-249A - -
13-022222-1-02225-33 - -
Expected result in "Number":
Regex expression (which worked in QGIS):
I tried to use something like this in ArcGIS PRO field calculator but it didn't work.
return re.search(r"""((\d+(?!(\d|-))\w)|(\d+(?!(\d|-))))""", Adr_for)
How should I do this to achieve expected result?
It's very nice solution but not perfect. It leaves empty spaces in field after values '33 ' and '249A ' (because between value and '-' there is space). I know I can fix it with some other basic function by second calculation pass but I would like to achieve that with one pass using regex, because it's something I used very often in QGIS.
BTW Is there any documents with description of all basic functions (like .split) of Field Calculator?
It will work, I suspect all the raw string triple quoting is doing something, just in the Python window all is good:
p = re.compile('((\d+(?!(\d|-))\w)|(\d+(?!(\d|-))))')
Adr_for = '13-0222222-1-02226-249A - -'
<_sre.SRE_Match object; span=(19, 23), match='249A'>