SA-MP Forums Archive
How to Replace part of String? - 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: How to Replace part of String? (/showthread.php?tid=301628)



How to Replace part of String? - Dragony92 - 05.12.2011

How to Replace part of String?
For example string "I'm going to work."
find "work" and reaplace with "school".
new string "I'm going to school."


Re: How to Replace part of String? - Luis- - 05.12.2011

I'm on my phone at the moment so if it doesn't work right i'm sorry.

pawn Код:
if(strfind("Im going to work", "work", true) != -1)
{
SendClientMessageToAll(Color here, "Im going to school");
}



Re: How to Replace part of String? - Dragony92 - 05.12.2011

I want to replacve unknow string with for example "|", find "|" and repleace with "\n|"....


Re: How to Replace part of String? - Luis- - 05.12.2011

Could you explain it a little more please.


Re: How to Replace part of String? - WLSF - 05.12.2011

You can use 'strdel' & 'strfind' & 'strins'

Try to compile and start this... (: example...
pawn Код:
public OnGameModeInit()
{
    new wii[30] = "I'm going to work";
    print(wii);
    strdel(wii,13,17);
    print(wii);
    strins(wii, "school", 13);
    print(wii);
    return 1;
}



Re: How to Replace part of String? - Dragony92 - 05.12.2011

I have unknow string with for exapmle this symbols "|", i want to replace every symbol with "\n|" and to place that whole replaced string into another...


Re: How to Replace part of String? - Dragony92 - 05.12.2011

Anyone?
I'm geting dini (get_Dini) with some comments, and i don't know the content of that dini, but i know that comments are separated by "|" and i want to use that simbol, to replace it ("\n|") and to make every comment in new line. And at the end to put that string into other string with other content, but that does not matter.
Understand?