正则表达式用括号提取字符串

时间:2014-11-17 19:40:43

标签: regex vb.net

我有以下字符串

 [2]  This is a test 1 <cr><lf>

 [3] This is a Test2   <cr><lf>

 [6] all  test5     <cr><lf>
 .

 .
 .

我已经在循环中阅读上述内容,以便我可以一次读取一行

   For Each parsedNewLine As String In ParseFileFooter.Split(New String()     {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)

我想提取2,这是一个test1,3,这是一个Test2和6这是一个数组或列表中的test5或任何其他集合 我想遍历集合并插入2作为数据库的一列,这是测试1作为数据库的另一列。 所以基本上我想要这个

col1     col2
 2        this is a test 1
 3        this is a test2
 6        all test5

1 个答案:

答案 0 :(得分:0)

正则表达式小提琴:http://regex101.com/r/pB1yX5/1

/^.*(\[\d+\])\W(.*)$/gmi
相关问题