SA-MP Forums Archive
StrFind from pos1 to pos2 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: StrFind from pos1 to pos2 (/showthread.php?tid=378869)



StrFind from pos1 to pos2 - Dragony92 - 19.09.2012

strfing(const string[],const sub[],bool:ignorecase=false,pos=0)

Here is defined only starting position, but i need some function with start and end postions, and also i need function to find char at exact position...
Is there any written solution for this?


Re: StrFind from pos1 to pos2 - Vince - 19.09.2012

strfind only finds a string within another string. I believe you're looking for strmid?


Re: StrFind from pos1 to pos2 - AndreT - 19.09.2012

strfind returns the position where the match is found, so:
pawn Код:
string = "123456789";
new pos = strfind(string, "5", true);
printf("%d", pos);
... would print 4.

So you can simply check if the return value is below your end position.

// Edit: Or maybe you mean what Vince posted. Hopefully either response is useful!


Re: StrFind from pos1 to pos2 - Dragony92 - 19.09.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
strfind only finds a string within another string. I believe you're looking for strmid?
I need to find string1 into another string2 but i want to define start and end postition in strgin2 in which i'm looking for string1. Do you understand me now?


Re: StrFind from pos1 to pos2 - Vince - 19.09.2012

Oh, ok, I get it. I think the best way to go about it is: store the part of string1 you want to check into the temporary string with strmid. Then use strfind in the temporary string to get what you want.


Re: StrFind from pos1 to pos2 - Dragony92 - 19.09.2012

I made that minute before your post , but thank you so much however. rep+