PDA

View Full Version : Is there a between(stringa,stringb,string) in c# like in scar?



Camaro'
08-19-2009, 10:05 AM
In scar there is a between function, which finds whats in the middle of a and b

between(a,b,s);

s is the string its looking in

So is there a function in c# for that?

senrath
08-19-2009, 10:08 AM
I don't think there is a built in one, but it shouldn't be too hard to make one.

Edit: This should work, but I have no clue how efficient it would be.

public string between(string start, string end, string toSearch)
{
string toReturn = "";
try
{
toReturn = toSearch.Substring(toSearch.IndexOf(start) + 1);
toReturn = toReturn.Substring(0, toReturn.IndexOf(end));
}
catch
{
toReturn = "";
}
return toReturn;
}

Boreas
08-19-2009, 10:22 AM
Yes. See SCAR manual under string functions.

senrath
08-19-2009, 10:23 AM
Yes. (C:/Program%20Files/SCAR%203.21/help/manual.htm)

Boreas, he wants to know if C# has it, not if SCAR has it.

Camaro'
08-19-2009, 10:28 AM
Boreas, he wants to know if C# has it, not if SCAR has it.

will test your function tomorrow, i need my beauty sleep.

Boreas
08-19-2009, 11:34 AM
Sorry read that backwards.

R0b0t1
09-17-2009, 05:42 AM
It's there, it's just named differen look it up on msdn?

noidea
09-17-2009, 05:55 AM
It's there, it's just named differen look it up on msdn?

Only 1 month late :p