-4
Here’s the code working:
string string_pick(string text, string tag, char caractere)
{
int index = text.IndexOf(tag);
return text.Substring(index + tag.Length, text.IndexOf(caractere, index + tag.Length + 1) - (index + tag.Length));
}
Working example:
string x = "kkkkkkkkkkkk jjjjjjjjjjj oloco icaro alguma coisa algumas palavras várias loucuras name:'icaro' lalala huhuasd sdiufhidf sdifuhisuhdf kkkkkkk";
string temporaria = string_pick(x,"name:'",'\'');
The temporary will be "expensive".
Well, how are you gonna mess with a string gigantic, I would like to just access that part of memory and not copy the string again (in the case of what the function argument is doing).
In C++ I solved so:
string string_pick(string *text, string tag, char caractere)
{
int index = (*text).find(tag);
return (*text).substr(index + tag.length(), (*text).find(caractere, index + tag.length() + 1) - (index + tag.length()));
}
First, decide whether it is C++ or C#. The second code does not compile in either. The first seems to compile in C#. Put a [mcve]. Take advantage and explain better what the intention is.
– Maniero
Dude, the second one was an attempt, it really doesn’t work, it went wrong here, but I’m just explaining what I want to understand?
– Ícaro Dantas
As for C++ or C#, it is because who knows in C++ probably would know in C# since little changes there...
– Ícaro Dantas
I’ll answer what gives but if you do what I asked you I could give a better answer.
– Maniero
I’m sorry, it’s my first post on this overflow, I’ll read what you sent
– Ícaro Dantas