C#Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I have an .aspx file with a string that is one line of data, this line has multiple instances of "ServiceName=" i'm working on a program that extracts each "ServiceName=" from the file, but using sting.INdexof only give me the first instance of "ServiceName=" how do iterate through all instances of "ServiceName=" when it is read as one line?
Alternatively, you can use a Regular Expression to get the value, and it will return an matching groups. Regular Expressions sound a bit overkill, but in your example, no knowledge is required.
string text = "ServiceName=";
MatchCollection matches = Regex.Match(sourceString, text, RegexOptions.SingleLine);
//No matches found
foreach(Match m in matches)
//Match is contained at m.Value;