Search the words it contains #
You can do this way, the explanation is in the code comments
using System;
using System.Linq;
public class Program
{
public static void Main()
{
string stringJson = "[{\"tipo\":\"simnao\",\"pergunta\":\"rwerw#erwerewr ?\",\"tag\":\"#acimadopeso\",\"resposta\":\"\",\"$$hashkey\":\"object:410\"},{\"pergunta\":\"werwerwerwer ?\",\"tag\":\"#diabetes\",\"resposta\":\"\",\"$$hashkey\":\"object:412\"},{\"pergunta\":\"werwerwer ?\",\"tag\":\"#idoso\",\"resposta\":\"\",\"$$hashkey\":\"object:414\"}]";
//Separa a string por aspas
string[] arrayString = stringJson.Split('\"');
//Procura as strings que contenha "#"
var listString = arrayString.Where(x => x.Contains("#")).ToList();
//Mostra o resultado
listString.ForEach(i => Console.Write("{0}\n", i));
}
}
Execute
Search the words that begin with #
In the question you said you wanted the words that contain #
, but I believe you want the words that begin with #
using System;
using System.Linq;
public class Program
{
public static void Main()
{
string stringJson = "[{\"tipo\":\"simnao\",\"pergunta\":\"rwerw#erwerewr ?\",\"tag\":\"#acimadopeso\",\"resposta\":\"\",\"$$hashkey\":\"object:410\"},{\"pergunta\":\"werwerwerwer ?\",\"tag\":\"#diabetes\",\"resposta\":\"\",\"$$hashkey\":\"object:412\"},{\"pergunta\":\"werwerwer ?\",\"tag\":\"#idoso\",\"resposta\":\"\",\"$$hashkey\":\"object:414\"}]";
//Separa a string por aspas
string[] arrayString = stringJson.Split('\"');
//Procura pelas strings que começam com "#"
var listString = arrayString.Where(x => x.FirstOrDefault() == '#').ToList();
//Mostra o resultado
listString.ForEach(i => Console.Write("{0}\n", i));
}
}
Execute