Author Topic: StrReplace not working? (Solved)  (Read 1783 times)

Code: [Select]
function stuff(%string)
{
for(%q=0;%q<getWordCount(%string);%q++)
{
%word=getWord(%string,%q);

%char=getSubStr(%word,0,5);

if(%char $= "src=\"")
{
strReplace(%word,"src=\"","");
strReplace(%word,"\"","");
warn(%word);
return %word;
}
}
}
Just returns %word as if strReplace never happened. No errors occur or anything.
« Last Edit: June 28, 2014, 11:35:04 PM by Thorfin25 »

you have to do %word = strReplace

I made this screwup myself before, strReplace returns a string, it does not automatically place the result in the string

I made this screwup myself before, strReplace returns a string, it does not automatically place the result in the string

The only function that I know of that will update the variable you use as an input is the nextToken() function

How do you replace 2 strings with two different ones in ine line? Like changing 1 to yes and 0 to no?

How do you replace 2 strings with two different ones in ine line? Like changing 1 to yes and 0 to no?
You don't. You do strReplace(strReplace(%string, %find1, %replace1), %find2, %replace2)