Method of using multiple delimiters for ASP Split function _ Application techniques

Source: Internet
Author: User

First, I'm aware that the function of split is to divide a string into an array of strings by the specified delimiter.

The ASP has this split, which is defined as the Dim split (ByVal Source As String, ByVal str As String) as String ()
source string, str is a separator
I have used vb.net to explain the type of return value and the type of parameter.
We can see how to use it.

In C #, that's how we use it.
String[] Split (string source,char[] char)
Here char is a char[] array, we can use this to set the new char[]{', ' so we just define a delimiter, and we can define multiple delimiters with new char[] {', ', '. ', ' # '}. This is a very simple usage in C #.

You can use multiple split characters in the ASP to split the string, what should be done?
The split in the ASP can only be used as a delimiter for a string parameter. I looked up some data and didn't find the split in the ASP to define multiple delimiters.
It seems that you have to deal with it, and finally find a way: First, the source string we think to be as a separator character is converted to a specific character, such as ",". We then use this particular delimiter to split the example as follows:

Copy Code code 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 implementation of the ASP in the split using multiple delimiters method.

Learning without thinking is not in, so the next thought of C # in the split work method.
How can you achieve a good efficiency? If it first uses char[0] to split the string, and then use Char[1] split, and then use Char[2],char[3] ... This is done multiple times and then an array is formed to get the final result. It seems that this is not a very efficient way to do it, and personally feel that it will not be handled in this manner.

So personally feel that the split in C # can also be in accordance with the method above ASP to achieve the split char[] split? It is more secure to turn the same characters in source and char[into a specific delimiter, perhaps not ', ' or a char that is basically impossible in our string. And then use this particular delimiter to split. This should be much more efficient.

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.