Skip to main content
Commonmark migration
Source Link

Solution with re module

###Solution with re module YouYou can use the built-in re module in Python for that.

import re
sr = re.split(' - |/',s)[1]

Field calculator view (where FeatureStr is the source field with 264K - Name of Place/FeatureType and Split is the output field with : Name of Place.

enter image description here

Pre-Logic Script Code:

def splitText(field):
  import re
  return re.split(' - |/', field)[1]

Field to be equal to:

splitText(!FeatureStr!)

Alternative solution with no re module:

!FeatureStr!.split(' - ')[1].split('/')[0]

###Solution with re module You can use the built-in re module in Python for that.

import re
sr = re.split(' - |/',s)[1]

Field calculator view (where FeatureStr is the source field with 264K - Name of Place/FeatureType and Split is the output field with : Name of Place.

enter image description here

Pre-Logic Script Code:

def splitText(field):
  import re
  return re.split(' - |/', field)[1]

Field to be equal to:

splitText(!FeatureStr!)

Alternative solution with no re module:

!FeatureStr!.split(' - ')[1].split('/')[0]

Solution with re module

You can use the built-in re module in Python for that.

import re
sr = re.split(' - |/',s)[1]

Field calculator view (where FeatureStr is the source field with 264K - Name of Place/FeatureType and Split is the output field with : Name of Place.

enter image description here

Pre-Logic Script Code:

def splitText(field):
  import re
  return re.split(' - |/', field)[1]

Field to be equal to:

splitText(!FeatureStr!)

Alternative solution with no re module:

!FeatureStr!.split(' - ')[1].split('/')[0]
added 125 characters in body
Source Link
Alex Tereshenkov
  • 30k
  • 4
  • 54
  • 119

You###Solution with re module You can use the built-in re module in Python for that.

import re
sr = re.split(' - |/',s)[1]

Field calculator view (where FeatureStr is the source field with 264K - Name of Place/FeatureType and Split is the output field with : Name of Place.

enter image description here

Pre-Logic Script Code:

def splitText(field):
  import re
  return re.split(' - |/', field)[1]

Field to be equal to:

splitText(!FeatureStr!)

Alternative solution with no re module:

!FeatureStr!.split(' - ')[1].split('/')[0]

You can use the built-in re module in Python for that.

import re
sr = re.split(' - |/',s)[1]

Field calculator view (where FeatureStr is the source field with 264K - Name of Place/FeatureType and Split is the output field with : Name of Place.

enter image description here

Pre-Logic Script Code:

def splitText(field):
  import re
  return re.split(' - |/', field)[1]

Field to be equal to:

splitText(!FeatureStr!)

###Solution with re module You can use the built-in re module in Python for that.

import re
sr = re.split(' - |/',s)[1]

Field calculator view (where FeatureStr is the source field with 264K - Name of Place/FeatureType and Split is the output field with : Name of Place.

enter image description here

Pre-Logic Script Code:

def splitText(field):
  import re
  return re.split(' - |/', field)[1]

Field to be equal to:

splitText(!FeatureStr!)

Alternative solution with no re module:

!FeatureStr!.split(' - ')[1].split('/')[0]
Source Link
Alex Tereshenkov
  • 30k
  • 4
  • 54
  • 119

You can use the built-in re module in Python for that.

import re
sr = re.split(' - |/',s)[1]

Field calculator view (where FeatureStr is the source field with 264K - Name of Place/FeatureType and Split is the output field with : Name of Place.

enter image description here

Pre-Logic Script Code:

def splitText(field):
  import re
  return re.split(' - |/', field)[1]

Field to be equal to:

splitText(!FeatureStr!)