SRL Archive - C/C++ Help and Tutorials

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


Camaro'

2009-08-19 06:05:23

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

2009-08-19 06:08:50

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

2009-08-19 06:22:25

Yes. See SCAR manual under string functions.

senrath

2009-08-19 06:23:34

From: Boreas
Yes.


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

Camaro'

2009-08-19 06:28:38

From: senrath
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

2009-08-19 07:34:32

Sorry read that backwards.

R0b0t1

2009-09-17 01:42:00

It's there, it's just named differen look it up on msdn?

noidea

2009-09-17 01:55:45

From: R0b0t1
It's there, it's just named differen look it up on msdn?


Only 1 month late :p