AnsweredAssumed Answered

Field calculator - regular expressions

Question asked by malauch on Sep 25, 2017
Latest reply on Sep 25, 2017 by bharold-esristaff

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.




Code Block:
import re
def regex(Adr_for):
    return"""((\d+(?!(\d|-))\w)|(\d+(?!(\d|-))))""", Adr_for)


How should I do this to achieve expected result?