0

Could someone tell me why I can't use the following code? It kept saying 'string' does not contain a definition for 'Match' and no extension method 'Match'.

string SearchText = "7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false";
string Regex = @"\btrue\b";
int NumberOfTrues = Regex.Match(SearchText, Regex).Count;
4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Mitja Bonca
0

string SearchText = "7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false";
string Regex = @"\btrue\b";
int NumberOfTrues = Regex.Match(SearchText, Regex).Count;

stirng doesn't contain a Match() extention method so you can't do Regex.Match().

take a look at this Link it might help you

Edited by ChrisHunter

0

Minor change, big difference:

using System.Text.RegularExpressions;

namespace DW_420515_CS_CON
{
   class Program
   {
      static void Main(string[] args)
      {
         string SearchText = "7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false";
         string strRx = @"\btrue\b";
         int NumberOfTrues = Regex.Matches(SearchText, strRx).Count;
      }
   }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.