Posted on: 9/26/2013 11:24:37 AM | Views : 310

Hey,
Take a search string of 'staff: any, due: 1 day, owner: samsung, ref: p41'
How would I turn this into key/value pairs;
staff: any due: 1 day owner: samsung ref: p41
I'm currently splitting on the comma, then IndexOf to strip out the keys, leaving the value, but wondering if Regex would be better?
 
 
 
strTagsArray = strSearchString.Split(",") For intTagsArrayCounter = 0 To strTagsArray.Length -1 intTagNameValSep = strTagsArray(intTagsArrayCounter).IndexOf(":") If Not intTagNameValSep = -1 Then intTagNameValLength = strTagsArray(intTagsArrayCounter).Length strTagName = strTagsArray(intTagsArrayCounter).Substring(0, intTagNameValSep).Trim.ToUpper() strTagValue = strTagsArray(intTagsArrayCounter).Substring(intTagNameValSep +1, (intTagNameValLength - intTagNameValSep) -1).Trim() If Not strTagName.IndexOf("ref& ...

Go to the complete details ...