Ajax
ASP
C,C++
C#,.NET
CSS,HTML
Delphi,Kylix
Experience
Flash
Java
JavaScript
PHP
Python
QT
SQL
ShellScript
VB
U :
P :
Register
Lost Password
Other Links
Code Archive
Save Giovanni
C#,.NET Category Code
Real Name
:
SharingCode.NET User
Subject
:
Replacement Split Function with multi character delim
Description
:
Replacement for the built in string split function in c# which only accepts a single char. Sample use to extract rows in an html table held in strGrid: string [] straRows=Split(strGrid , "</tr>");
/// <summary> /// This function acts like the old VB 6 split function and takes a delimiter of multiple /// characters and returns an array. It gets round the single char limitation of the .Net split. /// Unlike the original split though, the split function is case insensitive and no binary compare /// is available. /// </summary> /// <param name="v_strStringToSplit">The String that need to be split into component parts</param> /// <param name="v_strDelimiter">The delimited used to split eg "," for comma delimited</param> /// <returns>A string array</returns> public static string []Split(string v_strStringToSplit, string v_strDelimiter) { // List of potential delimiter characters char [] AvailableReplacementChars =new char[9] {'¬','|','º','¿','®','½', 'Ë','ı','²'}; char strReplaceCharacter=char.MinValue; if (v_strStringToSplit.Length >0 && v_strStringToSplit.Length >v_strDelimiter.Length ) { // Work out which delimiter is not used in this string to split foreach (char s in AvailableReplacementChars) { if (v_strStringToSplit.IndexOf(s)<0) { strReplaceCharacter=s; break; } } } // By now we should have found our delimiter so do a split if (strReplaceCharacter != char.MinValue) return v_strStringToSplit.Replace(v_strDelimiter,strReplaceCharacter.ToString() ).Split(strReplaceCharacter); else+ oStringWriter System.IO.StringWriter return new string [0] ; } }
Rating
:
4.00
(out of 5)
Visitor Voting Booth
:
Excellent
Very Good
Good
Fair
Poor
Copyright © 2006 SharingCode.NET . All rights reserved. Hosted By: SisNetworks