Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split a string with multiple delimiters in VBScript
#3
Solved: 6 Years, 3 Months ago
(02-09-2018, 01:03 AM)Ankur Wrote: This is a good question.

I am sure there can be multiple way to solve this. Here is one of the solutions I created for you.  You just need to call ALL the delimiters you use in the string and the custom SplitExtended function will do the rest.

Essentially I am using the built in Replace function to run n times where n is the number of delimiters you supply in the array.

Code:
Function SplitExtended (sPhraseFn, aDelimiters)
'Find total number of delimiters. Remember ubound starts from 0 index    
iNoOfDelimiters = UBound(aDelimiters)

'Replace all your delimiters with space      
For Iterator = 0 To iNoOfDelimiters
sPhraseFn = Replace (sPhraseFn, aDelimiters(Iterator)," ")    
Next    

SplitExtended = sPhraseFn
End Function

sPhrase = "My?name/isNandha-welcome^"
sPhraseClean = SplitExtended(sPhrase, Array("?","/","-","^"))
msgbox sPhraseClean
Wow!!!

thanks alot Ankur..
Reply
Jump to the post that solved this thread.


Messages In This Thread
RE: Split string from Special characters - by nandha - 02-10-2018, 06:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split function in string nidhishnair 13 63,398 07-07-2020, 03:47 PM
Last Post: helmzshelmz
Question Split Function Chaithra N 0 1,022 12-18-2019, 11:33 AM
Last Post: Chaithra N
  Replace a string in a word document with another string rekha.naik 8 15,031 11-14-2013, 12:58 PM
Last Post: pranikgarg
  Split Function diya 2 5,565 11-28-2012, 08:49 PM
Last Post: diya
Question Deatils on Split action with Nested type sams001 0 3,204 10-30-2012, 03:03 PM
Last Post: sams001

Forum Jump:


Users browsing this thread: 1 Guest(s)