简体   繁体   中英

how to split string using multichar string as delimiter in vba (excel)

Please tell me how to split a string into parts, using as a separator a multichar string, not a single symbol

for example

array = MySplit("xdatayydatazzz", "data");

and result

array(0) = "x"
array(1) = "yy"
array(2) = "zzz"

Um, why not just use:

arr = Split("xdatayydatazzz", "data")

Just to be sure, I tested this, and it works as expected. Docs on Split here .

First do a replace on the string eg data with a chosen character eg @ and then split on that:

secondstring = Replace("xdatayydatazzz", "data", "@")

array = Split(secondstring, "@")

Could nest the Replace inside the Split to keep to one step.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM