Skip to main content
1 of 2
Farid Cheraghi
  • 8.8k
  • 1
  • 24
  • 54

Standalone code

def f(s):
    idx = s.upper().index('S')
    s = s[:idx]
    for i in reversed(range(len(s))):
        if s[i].isalpha():
            s = s[i+1:]
            break
    return s

Testing

print f("6S2Olch1E")
print f("5B66S2Olch1E")
print f("54F5456B666S2Olch1E")

Field Calculator

f(!fieldName!)
Farid Cheraghi
  • 8.8k
  • 1
  • 24
  • 54