I have a program that I need to have a config file with value to be displayed in my program. Inside my text file I have Wireless = 1 & Cradle = 2.
In my program I will have a label populate the release number only and not the other characters.
private string searchFile(String path, String searchText)
{
string regex=@"(?i)(?<="+searchText+@"\s*=\s*)\d+";
return Regex.Match(File.ReadAllText(path),regex).Value;//version number
}
This is what I tried and it gives the correct output
string s="Wireless = 1 Cradle = 2";
Regex.Match(s,@"(?i)(?<=Wireless\s*=\s*)\d+").Value;//1