You need to sign in to do that
Don't have an account?
Kenn K.
Extracting number values in a text field then summing up
Hi there,
I have this field that gets populated by an external service and I want to extract the number values from it then sum the numbers up.
For instance, see the text below
United Kingdom: 3, Ireland: 1, Netherlands: 1, Spain: 2, Australia: 1
I would like to extract 3,1,1,2,1 and sum them individually to have 8. i.e. 3+1+1+2+1 = 8.
Thanks.
There might be a way to do this in a formula that escapes me right now, but you could do it in Apex by splitting the text into it's components, calling isAlpha on individual pieces, and only keeping the letters. The exact process will depend on what the text looks like.
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_methods_system_string.htm
This java function helped!
I love it. I'm kinda crap with regex, so I forget about them.
Coincidentally I'm parsing through a bunch of crappy data right now, and also decided I would do this to build a clean string of numbers from a potentially mixed bag:
That's a good approach. Great, Thanks!