Replace string: Difference between revisions
Jump to navigation
Jump to search
imported>Heeheehee m Formatting and stuff. (Template-breaking is baaad.) |
imported>Heeheehee Erm, didn't realize that I had removed the bit that uses the function. Heh. New sample up, as that last one wasn't very efficient. |
||
Line 33: | Line 33: | ||
code1={{CodeSample| | code1={{CodeSample| | ||
title=Code Sample| | title=Code Sample| | ||
description= | description=Replaces the center image of the Cyrpt (it's blank, don't worry) with some information regarding the noncombats of the zones.| | ||
code=<syntaxhighlight> | code=<syntaxhighlight> | ||
void main() | void main() | ||
Line 39: | Line 39: | ||
buffer results; | buffer results; | ||
results.append(visit_url()); | results.append(visit_url()); | ||
string | |||
string cyrpt = "<font size=1><- Muscle Mys -><br /><- Mox All -></font>"; | |||
results.replace_string("<img src=\"http://images.kingdomofloathing.com/otherimages/cyrpt/cyrpt5.gif\">", cyrpt); | |||
results.write(); | results.write(); | ||
} | } |
Revision as of 01:48, 12 April 2010
Function Syntax
buffer replace_string(buffer original ,string find ,string replace )
buffer replace_string(string original ,string find ,string replace )
- original is the starting string or buffer
- find is the text to find in original
- replace is the text to substitute for find
Searches through the supplied original text, replacing every instance of find with replace, and returns the result.
Code Sample
Replaces the center image of the Cyrpt (it's blank, don't worry) with some information regarding the noncombats of the zones.
void main()
{
buffer results;
results.append(visit_url());
string cyrpt = "<font size=1><- Muscle Mys -><br /><- Mox All -></font>";
results.replace_string("<img src=\"http://images.kingdomofloathing.com/otherimages/cyrpt/cyrpt5.gif\">", cyrpt);
results.write();
}
Special
Matches are made left-to-right, and once a portion of the supplied original is noted as a match, searching continues from the next character after said match.
Attention KoLmafia Experts!
We need your help; some details of this function's operation are unknown or unclear.
The following specific questions have been raised:
- Is the special note correct, or is the behavior different?
- I'm having a hard time clarifying what I mean... see Discussion page