How to use the Regex.Split() to split strings in C# ?

How to use the Regex.Split() to split strings in C# ?

As you might know the string Split method allows you to split a string only by a specified character. If you wish to split a string using the power of the regular expressions to specify the delimiter a good solution is to use the Regex.Split() method

using System.Text;
using System.Text.RegularExpressions;

string strText=” Development @@ of @@ online @@ pharmacy @@ web @@ solutions “;

foreach(string strItem in Regex.Split(strText,”@@”))

{
Response.Write(strItem + “<br>”);
}
will print:

Development
of
online
pharmacy
web
solutions

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.