s1 = 6/28/2010 4:46:36 PM
文字列とを分割したいs2 = 16:46:36.5013946
。それらを new に連結しますs3 = 20010062816463650
。しかし、s2を分割すると。私の正規表現は機能しません。今一時停止しました。
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace ConAppTest
{
class Program
{
static void Main(string[] args)
{
string s1 = ""; // date
string s2 = ""; // time
Console.WriteLine("{0}", DateTime.Now);
s1 = DateTime.Now.ToString();
Console.WriteLine("{0}", DateTime.Now.TimeOfDay);
s2 = DateTime.Now.TimeOfDay.ToString();
Regex regex1 = new Regex(@" |:|/"); //6/28/2010 2:19:21 PM
char[] separators1 = { ' ', '/' };
foreach (string sub1 in regex1.Split(s1))
{
Console.WriteLine("Word1: {0}", sub1);
}
Regex regex2 = new Regex(@":|."); //14:19:21.8771215
char[] separators2 = { ':', '.' };
foreach (string sub2 in regex2.Split(s2))
{
Console.WriteLine("Word2: {0}", sub2);
}
}
}
}
//output
//6/28/2010 4:46:36 PM
//16:46:36.5013946
//Word1: 6
//Word1: 28
//Word1: 2010
//Word1: 4
//Word1: 46
//Word1: 36
//Word1: PM
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2:
//Word2: