Just nu i M3-nätverket
Jump to content

C# - ta ut ett ord i en text


Recommended Posts

Ett exempel:

using System;

using System.IO;

using System.Text.RegularExpressions;


namespace Grep


class Class1



static void Main(string[] args)


String file = @"c:\temp\howdy.txt";

String pattern = "Howdy";


Regex reg = new Regex(pattern);


StreamReader reader = new StreamReader(file);


while (reader.Peek() != -1)


String line = reader.ReadLine();

Match m = reg.Match(line);

if (m.Success) Console.WriteLine(m.ToString());








Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...