I want to split a string field after the first word using the space as a delimiter so that:
"WA ROSSOUW ORANJE BELEGGINGS" becomes "ROSSOUW ORANJE BELEGGINGS".
I am using ArcMap 10.
nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
-
This worked for me. THANKS! Incidentally, if I just wanted to extract ONLY the first word, how would you suggest I modify the VBA code?Phil– Phil2014年04月29日 17:25:04 +00:00Commented Apr 29, 2014 at 17:25
3 Answers 3
Or the two-liner using Python:
(in Show Codeblock)
import string
in Class = :
string.join(!YourFieldName!.lstrip().split(' ')[1:],' ')
The lstrip()
makes sure there are no leading spaces which will cause problems
answered Mar 30, 2012 at 12:00
-
2Python string module functions are deprecated (docs.python.org/library/string.html). String object methods are preferred, e.g. ' '.join(!YourFieldName!.lstrip().split(' ')[1:])user2856– user28562012年04月03日 03:28:42 +00:00Commented Apr 3, 2012 at 3:28
-
shorter too, so can't argue with that.Stev_k– Stev_k2012年04月03日 08:32:04 +00:00Commented Apr 3, 2012 at 8:32
You can simply use the following VBA code in field calculator :
Split( [Your_Field_Name] , " ", 2)(1)
answered Mar 30, 2012 at 11:27
-
Thanks, but I am getting a "failure during processing" message when I use it.Annie– Annie2012年03月30日 11:50:44 +00:00Commented Mar 30, 2012 at 11:50
you can use python if you want.
text = "WA ROSSOUW ORANJE BELEGGINGS"
sptext = text.split(" ")
result = ' '.join(sptext[1:len(sptext)])
print result
>>>"ROSSOUW ORANJE BELEGGINGS"
answered Mar 30, 2012 at 12:02