I have collection of similar strings
for example :
string 1: Customer’s first Name is john, his last name is glueck,his company name is abc def technolgies llc, he has a balance of 60 dollars.His spending rate is +3.45%
string 2: Customer’s first Name is steve, his last name is johnston,his company name is xyz corporation, he has a balance of 800 dollars.His spending rate is -212.86%
Now I have to extract the values like john,glueck,abc def technolgies llc,60,+3.45 from the string 1 and steve,johnston,xyz corporation,800,-212.86 from the string 2.
In our production environment each string is quite large and I have around 83 fields to extract from each string. What is the best way to extract these values?
Is there any method that does opposite of string.format, which takes the reference string & the actual string and returns back the extracted values?
A regular expressions will do the trick.
OUTPUT
After that you can perform some simple string parsing to get numeric values from the strings. Further you will probably have to write a more robust regular expression if there are some variations in the format of the inputs.