Asp Split functions using multiple delimiters

Source: Internet
Author: User

First, I know the role of the Split function is to Split a string into a String Array Based on the specified delimiter.

This Split is defined in ASP as dim Split (byval source as string, byval str as string) as string ()
Source is the source string, str is the Separator
I used VB.net to describe the type of the returned value and the type of the parameter.
You can see how to use it at a glance.

In C #, we use
String [] Split (string source, char [] char)
Here Char is an array of Char []. We can set new char [] {','} in this way to define only one delimiter, you can also use new char [] {',', '. ',' # '} to define multiple delimiters. This is a simple usage in C.

In ASP, multiple delimiters can be used to separate strings. How can this problem be solved?
The Split in Asp can only be a string parameter as a delimiter. After reading some documents, I did not find the method for defining multiple delimiters in ASP.
It seems that we have only handled it by ourselves. Finally, we can find a method: first, convert all the characters in the source string that we think will be treated as delimiters into a specific character, such as ",". Then we use this specific delimiter for segmentation. The example is as follows:

Copy codeThe Code is as follows: lcontent = Replace (lcontent ,".",",")
Lcontent = Replace (lcontent ,"",",")
Lcontent = Replace (lcontent ,". ",",")
Lcontent = Replace (lcontent ,",",",")
Lcontent = Replace (lcontent ,"\",",")
Lcontent = Replace (lcontent ,"/",",")
Lcontent = Replace (lcontent ,"#",",")
Lcontent = Replace (lcontent ,"*",",")
Lcontent = Replace (lcontent ,"&",",")
Lcontent = Replace (lcontent ,":",",")
Lcontent = Replace (lcontent ,";",",")
Rec = Split (lcontent ,",")

In this way, the Split method in Asp uses multiple delimiters.

Learning without thinking about it is not in progress, so next I thought of the working method of Split in C.
How can we achieve good efficiency? If it uses char [0] to split the string, then use char [1] to separate it, and then use char [2], char [3]... in this way, after multiple splits, an array is formed to obtain the final result. It seems that this is not very efficient, and I personally think it will not be used to deal with it.

So I personally think that the Split in C # can also be Split by the char [] of the Split based on the method in ASP above? First, convert the same characters in source and Char [] into a specific delimiter, maybe not ',' or a Char that is basically impossible in our string, which is more secure. And then use this specific delimiter to separate. The efficiency should be much higher.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.