Difference between pages "Talk:Group string" and "Insert"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Heeheehee
m
 
imported>Bale
m
 
Line 1: Line 1:
(Move from main page)
+
{{
 +
#vardefine:name|insert}}{{
 +
#vardefine:return_type|buffer}}{{
  
group(0) matches the entire expression. After that, group(n) matches the expression defined by the nth set of parentheses.--[[User:Heeheehee|Heeheehee]] 06:45, 3 March 2010 (UTC)
+
FunctionPage|
 +
name={{#var:name}}|
  
That's the function group(); this page is for group_string(). I know, it's hard to tell 'cause of how wikis handle page names, I'll make that a bit clearer! --[[User:StDoodle|StDoodle]] 15:45, 5 March 2010 (UTC)
+
function1={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|buffer|original}}|
 +
parameter2={{Param|int|strStart}}|
 +
parameter3={{Param|string|stuff}}|
 +
p1desc={{Pspan|original}} is the buffer to modify|
 +
p2desc={{Pspan|strStart}} marks where to insert the string|
 +
p3desc={{Pspan|stuff}} is the string to insert|
 +
}}|
  
Perhaps this should be shifted down with the rest of the regex stuff? Even though it doesn't make use of their datatypes, it is a regex function. --[[User:StDoodle|StDoodle (#1059825)]] 06:19, 7 May 2010 (UTC)
+
function_description=Returns the buffer {{pspan|original}} with the string {{pspan|stuff}} inserted at {{pspan|strStart}}.|
  
* That ''is'' weird. It uses regexes, but not matchers. I'm not quite sure what to make of it. Since it doesn't need find or the other requirements that regex functions require it is rather stand alone, unlike those functions so I can see some reason to let it be separate from that bunch. --[[User:Bale|Bale]] 06:42, 7 May 2010 (UTC)
+
code1={{CodeSample|
 +
title=Code Sample|
 +
description=Inserts a "Refresh page" link to the Pyramid inside KoL's default border.|
 +
code=
 +
<syntaxhighlight>
 +
buffer results;
 +
results.append(visit_url());
  
* I thought some more about the problem and I decided you definitely should not move this to the regex section. I'm going to be saying some things about how regex functions are used and none of that will apply to this function. It will be a glaring exception to several rules. However, on this page you can refer to the [[Regular Expressions]] page for information on creating a regex. --[[User:Bale|Bale]] 08:26, 7 May 2010 (UTC)
+
int strEnd = results.index_of("height=137 border=0>");
 +
if(strEnd > 0) {
 +
  results.insert(strEnd + 20,"<br /><div align='center' class='tiny'><a href='pyramid.php'>Refresh page</a></div>");
 +
}
 +
results.write();
 +
</syntaxhighlight>
 +
}}|
  
 +
see_also={{SeeAlso|delete}}|
 +
}}
  
==Category==
+
[[Category:String Handling Routines]]
 
 
Ok, so Heeheehee recently moved group_string() down with the regex functions. This is what I was leaning towards in the first place (see above) but Bale noted that it wouldn't fit with the description for said functions. If this references [[Regular_Expressions#Using Regexes in KoLmafia|Using Regexes in KoLmafia]], I think we'd be better off making a note of group_string() being an exception to the "requires a defined matcher" rule rather than leaving it out of the regex section. Thoughts? --[[User:StDoodle|StDoodle (#1059825)]] 06:54, 5 July 2010 (UTC)
 
: It's easier to locate this way. I mean, who expects group_string() to be up in the unclassified functions, as opposed to those that use regex? --[[User:Heeheehee|Heeheehee]] 17:43, 5 July 2010 (UTC)
 

Revision as of 05:14, 22 May 2010

Function Syntax

buffer insert(buffer original ,int strStart ,string stuff )

  • original is the buffer to modify
  • strStart marks where to insert the string
  • stuff is the string to insert

Returns the buffer original with the string stuff inserted at strStart.

Code Sample

Inserts a "Refresh page" link to the Pyramid inside KoL's default border.

buffer results;
results.append(visit_url());

int strEnd = results.index_of("height=137 border=0>");
if(strEnd > 0) {
   results.insert(strEnd + 20,"<br /><div align='center' class='tiny'><a href='pyramid.php'>Refresh page</a></div>");
}
results.write();

See Also

delete()