| || |
Split with escape character
aInput = Split(sInput,",")
The above function takes comma seperated inputs like 30,"Service Contract",2
This format is reqd for processing the business flow in the function. There are more than 15 functions that take comma seperated list as input in various fashions of integers and strings.
At this point, there is a scenario where the string itself has comma in it as in Opptys,Leads so the sInput becomes 30,Opptys,Leads,2
How can we write a common function that will escape the , if the string can be passed as Opptys\,Leads.
Thanks in advance!!
Re: Split with escape character
Its not great but this would work
<font class="small">Code:</font><hr /><pre>input = "30,Opptys\,Leads,2"
endOfString = false
locationCounter = 0
Do Until endOfString = true
location = InStr(1, input, ",")
ReDim Preserve output(locationCounter)
If location <= 0 Then
output(locationCounter) = input
endOfString = true
If Mid(input, (location - 1), 1) = "\" Then
location = InStr((location + 1), input, ",")
input = Replace(input, "\", "")
location = location - 1 'because just taken the escape out of the string
output(locationCounter) = Left(input, (location - 1))
input = Right(input, (Len(input) - location))
locationCounter = locationCounter + 1