How do i use regular expression to extract data using regular expression?
e.g:
Host Name: IT786P20
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 2 Build 2600
OS Manufacturer: Microsoft Corporation
How do i extract Host Name only??
StephenPosted Dec 11, 2007, 6:28 PM
To get text from a .txt file, use System.IO.StreamReader (see http://msdn2.microsoft.com/en-us/library/system.io.streamreader.aspx )
StreamReader has a constructor that takes a string path to a text file to be read; once it is constructed, the text can be read using methods ReadLine() and ReadToEnd(), both of which return strings.
(disclaimer: I work for Microsoft, but my opinions are my own).
Raymond TeoPosted Dec 6, 2007, 11:58 PM
Ryan AlfordPosted Nov 28, 2007, 8:48 AM
example:
String input = "Company Name: Contoso, Inc.";
Match m = Regex.Match(input, "Company Name: (.*$)");
MessageBox.Show(m.Groups[1]);
This example would display:
Contoso, Inc.