fork download
  1. using static System.Console;
  2.  
  3. public class Program {
  4. public static void Main() {
  5. var texto = "kkkkkkkkkkkk jjjjjjjjjjj oloco icaro alguma coisa algumas palavras várias loucuras name:'icaro' lalala huhuasd sdiufhidf sdifuhisuhdf kkkkkkk";
  6. WriteLine(StringPick(texto, "name:'", '\'')); //provavelmente é uma má ideia colocar a abertura do delimitador junto com a tag
  7. WriteLine(StringPick(texto, "age:'", '\'')); //não achou a tag
  8. WriteLine(StringPick(texto, "name:'", ',')); //não achou o demimitador
  9. }
  10. public static string StringPick(string text, string tag, char closing) {
  11. int index = text.IndexOf(tag);
  12. int start = index + tag.Length;
  13. int end = text.IndexOf(closing, start + 1);
  14. return index >= 0 ? text.Substring(start, (end >= 0 ? end : text.Length) - start) : "";
  15. }
  16. }
  17.  
  18. //https://pt.stackoverflow.com/q/135518/101
Success #stdin #stdout 0.02s 17236KB
stdin
Standard input is empty
stdout
icaro

icaro' lalala huhuasd sdiufhidf sdifuhisuhdf kkkkkkk