Select to view content in your preferred language

VB Script to replace strings

5685
10
Jump to solution
07-07-2015 10:57 AM
DeidreA
Emerging Contributor

Hello everyone! Very new to the GIS industry, but I'm hoping to learn more down the line. Forgive me if this is a very basic question.

Right now I'm having trouble doing something I think should be very simple. I'm just to replace a string in a field with another string using the Field Calculator. However, every time I run the calculation absolutely nothing appears to happen to the records within the field in question. I am working with ~4,000 records and some of them have unnecessary leading zeroes in them. Normally I would run a calculation that would remove all the leading zeroes but certain records need it while others don't. As a result, I thought it would be easier to just entirely replace the ones that have the unnecessary leading zeroes.

Here is what I'm entering into the Field Calculator

DATE_TEXT

= Replace([DATE_TEXT], "011/12/2014","11/12/2014")

The numbers are both set to strings and I have made sure to check the VB Script parser. I've also tried it using the Python parser:

DATE_TEXT

=!DATE_TEXT!.replace("011/12/2014","11/12/2014")

But with no luck. What am I doing wrong? Is it the settings? I'm working with a standalone shape file in Arc 10.3.

0 Kudos
10 Replies
DanPatterson_Retired
MVP Emeritus

yes.... as long as you reassign a to itself as in your case, but look at mine...that was why I was wondering about the field name.  Anyway slicing with reassignment as in my edits also works...without reassignment you just get a view not a copy

0 Kudos