Advertisement
FoxHound

getPartOfString

Mar 6th, 2011
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.56 KB | None | 0 0
  1. stock getPartOfString(const string[], strpos=0, sep=' ',secondsep=256) {    //by FoxHound
  2.     new delstr[256],count[2]={0,...}; secondsep = (secondsep!=256) ? secondsep : sep;
  3.     format(delstr,256,"%s",string);
  4.     for(new i[2]={0,...}; i[0]<strlen(delstr); i[0]++) {
  5.         if(delstr[i[0]]==sep) {
  6.             count[1]++;
  7.             if(((count[0]+1)==strpos) && !i[1]) { strdel(delstr,0,i[0]+1),i={0,1},sep=secondsep; continue; }
  8.             else if(i[1]) { strdel(delstr,i[0],strlen(delstr)); }
  9.             else { count[0]++; continue; } } }
  10.     if(count[1]<strpos) { delstr="\0"; }
  11.     return delstr; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement