1

我有一列包含以下数据

NStreetNames
1245 Thfs Ext. drive.
2454 saaa Ext. Drive.

我希望输出位于 3 个不同的列中,例如

One    Two        Three

1245  THfs Ext.   Drive

2454  Saa Ext.    drive

 public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        /*
          Add your code here
        */
        string Val = Row.NStreetNames.ToString();
        Match match = Regex.Match(Val, @"^(?<One>\w+) (?<Two>\w+)(?: (?<Three>\w+))?$");
        if (match.Success)
        {
            string o = match.Groups["One"].Value;
            string t = match.Groups["Three"].Value;
            string th = null;
            if (match.Groups["Two"].Success)
            {
                th = match.Groups["Two"].Value;
            }

            Row.StreetNumber = o;
            Row.Street = t;
            Row.Address = th;
        }
        else
            Row.StreetNumber = Row.NStreetNames.ToString();
    }

此代码只是将我的所有数据重定向到三个

4

1 回答 1

2

假设第二列和第三列总是以句点结尾,.那么您可以使用以下内容提取所有信息:

^(?<One>\d+)\s(?<Two>[\w\s]+\.)\s(?<Three>\w+)\.$
于 2013-08-20T15:48:46.723 回答