jstreeb

Right Trim String after Special Char

Discussion created by jstreeb on Feb 25, 2011
Latest reply on Apr 3, 2012 by krbrevard
Ok, so I know it's probably something really simple that I'm missing, but, I need some help getting this to work.
I've got an attribute field !ADDRESS_GEO!.  This is a text field that has addresses in it, but they were user submitted addresses that include ";" and "#" type information.  An example address would be "123 W Main St ; STE 120" and "234 E Main St #D".  To geocode these using the geocode service I've got, I have to strip out the ";" and "#" characters as well as anything to the right of them and ideally leading and trailing spaces from the resulting string.  I'm using the Calculate Field geoprocessing tool in 9.3.1 Sp2.  I've tried a couple of expressions I thought would work to no avail, so, if anyone can help...

I've tried the expressions:
!ADDRESS_GEO!.rstrip(';')

and

!ADDRESS_GEO![:(!ADDRESS_GEO!.find(';'))]

If it makes any difference, the error I'm getting is:

"ERROR 000539: Error running expression: [:(.find(';'))] <type 'exceptions.SyntaxError'>: invalid syntax (<string>, line 1)"

Outcomes