Wednesday, 11 September 2013

Create a single string using regex

Create a single string using regex

How do i read the following text into a single string using c# regex?
:70://this is a string //this is continuation of string even more text 13
so for example, the above needs to return
this is a string this is continuation of string even more tex
I've thought something like this would do the job, but it doesn't return
any group values
foreach (string in inputstring)
{
string[] words
words = str.Split(default(string[]),
StringSplitOptions.RemoveEmptyEntries);
foreach (string word in words)
{
stringbuilder.Append(word + " ");
}
}
Match strMatch = Regex.Match(stringBuilder, @"[^\W\d]+");
if(strMatch.Success)
{
string key = strMatch.Groups[1].Value;
}
perhaps, i'm going about this all wrong, but i need to use the regex
expression to formualte a single string from the example string.

No comments:

Post a Comment