CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sun, 31 Aug 2025 11:17:05 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20080328194610
location: https://web.archive.org/web/20080328194610/https://www.daniweb.com/code/snippet830.html
server-timing: captures_list;dur=0.534214, exclusion.robots;dur=0.019129, exclusion.robots.policy;dur=0.007931, esindex;dur=0.013240, cdx.remote;dur=20.610925, LoadShardBlock;dur=125.470378, PetaboxLoader3.datanode;dur=76.452408
x-app-server: wwwb-app211
x-ts: 302
x-tr: 170
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app211; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sun, 31 Aug 2025 11:17:06 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Fri, 28 Mar 2008 19:46:09 GMT
x-archive-orig-server: Apache/2.2
x-archive-orig-x-powered-by: PHP/5.1.6
x-archive-orig-set-cookie: bblastactivity=0; expires=Sat, 28-Mar-2009 19:46:09 GMT; path=/; domain=.daniweb.com
x-archive-orig-cache-control: private
x-archive-orig-pragma: private
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Fri, 28 Mar 2008 19:46:10 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Fri, 28 Mar 2008 19:46:10 GMT", ; rel="memento"; datetime="Fri, 28 Mar 2008 19:46:10 GMT", ; rel="next memento"; datetime="Sat, 05 Apr 2008 19:53:12 GMT", ; rel="last memento"; datetime="Sun, 23 Aug 2009 12:41:00 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_2_20080328180707_crawl106-c/52_2_20080328194430_crawl104.arc.gz
server-timing: captures_list;dur=0.558715, exclusion.robots;dur=0.022098, exclusion.robots.policy;dur=0.009522, esindex;dur=0.010882, cdx.remote;dur=7.836614, LoadShardBlock;dur=59.431765, PetaboxLoader3.datanode;dur=179.312374, load_resource;dur=563.281253, PetaboxLoader3.resolve;dur=381.078295
x-app-server: wwwb-app211
x-ts: 200
x-tr: 725
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
Split text into substrings seperated more than one character - csharp
Split text into substrings seperated more than one character
•
•
•
•

What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 302,143 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,607 IT professionals currently interacting right now! If you are in the IT industry or are just a technology enthusiast, you might find just what you're looking for in DaniWeb. Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Modernize Legacy Data with Sybase
Enables creating substring arrays from strings seperated by character sets .
In c# there is a built-in split method with which you can create a substring array seperated by one character from a string as follows : // string seperated by colons ';' string info = "mark;smith;123 csharp drive;toronto;canada"; string[] arInfo = new string[4]; // define which character is seperating fields char[] splitter = {';'}; arInfo = info.Split(splitter); for(int x = 0; x < arInfo.Length; x++) { Response.Write(arInfo[x] + "<br>"); } but what if i want to create a substring array seperated by more than one characters like '#$' or '#$%' ? The following method does exactly what i mean : public string[] SplitText(string textToSplit,string splitter) { if (textToSplit.IndexOf(splitter) != -1 && splitter != string.Empty) { int count = 0; string temp = textToSplit; int count2 = splitter.Length; while (temp.IndexOf(splitter) != -1) { int seq = temp.IndexOf(splitter); int top = seq + count2; temp = temp.Remove(0, top); count++; } string[] splittedText = new string[count + 1]; int i = 0; while (textToSplit.IndexOf(splitter) != -1) { int seq = textToSplit.IndexOf(splitter); splittedText[i] = textToSplit.Substring(0, seq); textToSplit = textToSplit.Remove(0, (seq + count2)); i++; } splittedText[count] = textToSplit; return splittedText; } return new string[] {textToSplit}; }
Comments (Newest First)
kathirvelmm | Newbie Poster | 2 Days Ago

•
•
•
•
Good for single splitter the coding is quiet easy.
Which could be used for multiple characters with a single "String.replace" operation
[code]
output:
mark;smith;123 csharp drive;toronto;canada
which could be used with simple splitter coding
Which could be used for multiple characters with a single "String.replace" operation
[code]
c# Syntax (Toggle Plain Text) - string info = "mark\nsmith\n123 csharp drive\ntoronto\ncanada";
- string mystring = info.Replace("\n", ";");
c# Syntax (Toggle Plain Text)
output:
mark;smith;123 csharp drive;toronto;canada
which could be used with simple splitter coding
Post Comment