How to pull numbers out of a string

Here’s a little function to pull numbers out of a string.

import re

def calculate(value):
  newVal = re.sub("[^0-9]", "", value)
  if newVal == "":
    return 0
  elif newVal is None:
    return 0
  else:
    return newVal

calculate( !Size! )


Happy GISing!
Lindsy Hales Bentley

Popular posts from this blog

How to Create a 3D Surface

How to Pull a House Number Out of an Address

3D GIS