3

I'm trying to use the split tool in ArcGIS to add an underscore. Trying to make "ABC11111" look like "ABC_11111". Don't have much experience using Python or VB Script but this is what I have created with little success:

Split( [SURVSTR_ID] , "_", 3)(ABC).
2
  • Do you want to add the underscore in between C and the first "1", that is the fouth position? What is the condition/criteria where the underscore must be?
    – Delonix R.
    Apr 1, 2016 at 17:19
  • I needed to place it after the C. Thank you for your help, and below Paul has showed me the way to make the function work in VB! But thanks Delonix!
    – Bryden C
    Apr 1, 2016 at 17:24

1 Answer 1

5

Strings in Python are immutable, so you could use the following (SO reference):

!SURVSTR_ID![:3] + "_" + !SURVSTR_ID![3:]

>>> "ABC11111"[:3] + "_" + "ABC11111"[3:]
'ABC_11111'

Similar results with VB script (probably a cleaner way):

Left([SURVSTR_ID], 3) & "_" & Mid([SURVSTR_ID],4)
2
  • The VB Script Worked perfectly. Thank you for your great help Paul!!
    – Bryden C
    Apr 1, 2016 at 17:21
  • if this worked for you then please mark as the answer
    – Midavalo
    Apr 1, 2016 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.