I have a GPS station feature dataset and I need to label using field NAME. However, I need to label only the number, for example in the field NAME the name are GPS123, STATION 239, STN 325 but the label need only appear 123,239 and 325. I already tried using this VB script expression but its not work properly.

Function FindLabel ([NAME])
  FindLabel = [NAME]
End Function
  • Is it always three digits, and always last in your string? If so, you can use that as base to split the string and/or only display those three characters.
    – Martin
    Commented Nov 3, 2014 at 8:07
  • hi martin.. no, some data are 2 digits and some are 4 digits, and the number always last in string.
    – user
    Commented Nov 3, 2014 at 8:18

1 Answer 1


You can achieve this with a regular expression. The current logic below assumes the format is as described above, i.e. 1 or more numbers in a single group at the end of the string. So it will not find numbers embedded in the string "bob123gps456".

Function FindLabel ( [FeatureClassName]  )
  dim s, reg, mc
  s =  [FeatureClassName]
  set reg = new RegExp
  reg.IgnoreCase =True
  reg.Global = False
  reg.Pattern = "\d+$"
  set  mc = reg.Execute(s)
  if mc.count = 0 then
    FindLabel = "no number"
    findLabel = mc.Item(0)
  end if
End Function
  • Hi Hornbydd... i already try it and its work...tq so much..
    – user
    Commented Nov 4, 2014 at 2:31

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.