Brooke, I'm looking for a script that deletes or replaces some characters from string values. I have one field where the string values will be used as names for feature classes when I split the feature class into many, one for each feature. Example: I would like to replace the text "1630089 - 1630" with "16300891630" or "1630089_1630" (I'm not sure which one will work). It is the " - " part of the string that is the problem. I see that I might find a sollution by using several of the scripts posted by you, but if there is one script that will do the job, I'm grateful for directions.
Thanks!
Ivar
Replacing the text in a string field can be accomplished with the Find and Replace tool available in core ArcGIS Desktop at all license levels. To do this:
1) Start editing.
2) Open the attribute table.
3) Click on the field heading containing the field text you want to replace to ensure only that field will be altered.
4) Click the Options button at the bottom of the attribute table and choose Find and Replace.
4) A dialog box opens with two tabs. Select the Replace tab. Choose to find " - " (without the quotes). If you want to replace it with an under score (like 1630089_1630), enter "_" (without the quotes) in the Replace input box. If you want to combine the text on either side of the " - " (like 16300891630) simply leave the Replace input box blank.
![]() |
5) Check on the Search Only Selected Field(s) option and select to match Any Part of the text.
6) Select Replace to replace the values one at a time (might be good to do this for the first couple to make sure you are getting the desired result) or select Replace All to replace all of the values at once.
7) Save edits and stop editing.
Thanks for reading my blog and posting your question, Ivar. I hope this does what you are looking to accomplish.

7 comments: