Answers for "string.split c# stack overflow"

C#
0

string.split c# stack overflow

string content = @"[email protected] [email protected] ""Information"" ""Hi there""";

string firstEmail = content.Substring(0, content.IndexOf(" ", StringComparison.Ordinal));
string secondEmail = content.Substring(firstEmail.Length, content.IndexOf(" ", firstEmail.Length + 1) - firstEmail.Length);

int firstQuote = content.IndexOf("\"", StringComparison.Ordinal);
string subjectandMessage = content.Substring(firstQuote, content.Length - content.IndexOf("\"", firstQuote, StringComparison.Ordinal));

String[] words = subjectandMessage.Split(new string[] { "\" \"" }, StringSplitOptions.None);

Console.WriteLine(firstEmail);
Console.WriteLine(secondEmail);
Console.WriteLine(words[0].Remove(0,1));
Console.WriteLine(words[1].Remove(words[1].Length -1));
Posted by: Guest on January-22-2021
0

string.split c# stack overflow

var stringValue = "[email protected] [email protected] \"Information\" \"Hi there\"";

var parts = Regex.Matches(stringValue, @"[\""].+?[\""]|[^ ]+")
            .Cast<Match>()
            .Select(m => m.Value)
            .ToList();

//parts: [email protected]
          [email protected]
          "Information"
          "Hi there"
Posted by: Guest on January-22-2021
0

string.split c# stack overflow

string[] readText = File.ReadAllLines(' ');
   //Take value of first 3 fields by simple readText[index]; (index: 0-2)

   string temp = "";

   for(int i=3; i<readText.Length; i++)
   {    
    temp += readText[i];
   }
Posted by: Guest on January-22-2021
0

string.split c# stack overflow

using (var tfp = new Microsoft.VisualBasic.FileIO.TextFieldParser("input.txt")) {
    for (tfp.SetDelimiters(" "); !tfp.EndOfData;) {
        string[] fields = tfp.ReadFields(); 
        Debug.Print(string.Join(",", fields)); // "[email protected],[email protected],Information,Hi there"
    }
}
Posted by: Guest on January-22-2021

C# Answers by Framework

Browse Popular Code Answers by Language