Difference between revisions of "String Handling Routines"

From Kolmafia
Jump to navigation Jump to search
 
(235 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
relrolricc
+
{{TOCright}}
[http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/dqusiv.html pilot insurance company toronto] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/ikkhpt.html acetic acid and calcium carbonate] [http://www.plurpage.com/classifieds/cache/lxdafk.html supreme court justice vote] [http://aura.c3.hu/thumb/wfkcib.html mozilla firefox mac os x download] [http://2001.c3.hu/mas/gchedr.html video camera for inside car rear view mirror] [http://www.stillwaterhomes.com/listings/images/pic/wqvbqi.html erotic info latin remember woman] [http://www.olemissfans.com/chatpro/image/hpwlik.html you are my lucky star midi] [http://www.easypayinfo.com/subscribe/tmp/jmimbv.html powerpoint presentation on diabetes] [http://www.salona-yachts.eu/misc/itfgli.html setting up a small business canada] [http://2001.c3.hu/mas/lcfite.html today hit music] [http://troniny.ovh.org/gallery/layout/usnfnu.html where can i listen to classical music] [http://www.stillwaterhomes.com/listings/images/pic/fndoxo.html machinist employment] [http://www.lowell.edu/styles/old_style/css/bqbrcs.html virtual pinball machine] [http://activeimage.c3.hu/css/wdaxxo.html performance bond definition] [http://www.salona-yachts.eu/misc/upidnr.html teresas restaurant] [http://maps.my2gig.com/cache/qvpbjc.html ashley bond] [http://www.stillwaterhomes.com/listings/images/pic/lgkoiq.html umax scanners] [http://www.stillwaterhomes.com/listings/images/pic/cmrdbe.html make me blind when your eyes close] [http://activeimage.c3.hu/css/elwtfk.html popular names for baby girls] [http://2001.c3.hu/mas/rskgxx.html made in usa jacket] [http://www.salona-yachts.eu/misc/tcchbq.html erik the midget] [http://ndr.hu/rhodes/pwofjd.html wood stapler] [http://www.easypayinfo.com/subscribe/tmp/cfscja.html motorola radios los angeles] [http://www.easypayinfo.com/subscribe/tmp/rmbfmc.html your mercy goes much deeper] [http://www.stillwaterhomes.com/listings/images/pic/qdkdiw.html naked russian] [http://maps.my2gig.com/cache/nniaje.html kidney stones pain] [http://www.lowell.edu/styles/old_style/css/iojthf.html download love ringtones] [http://www.easypayinfo.com/subscribe/tmp/xvhfeo.html sage medical products] [http://troniny.ovh.org/gallery/layout/gitxtx.html target pharmacy] [http://ndr.hu/rhodes/wddvjl.html ablation plasma] [http://www.systemsupport.und.edu/cache/avatars/emo/jxahjm.html humour ringtone] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/toixvl.html no salt cooking] [http://2001.c3.hu/mas/bxvnml.html software access point wireless] [http://informer.siam.edu/themes/hm/wxbwld.html discount codeine] [http://maps.my2gig.com/cache/btobpk.html 3 manual mazda service] [http://www.housing.und.edu/reshalls/blog/wp-content/uploads/2007/04/img/ungssm.html free kyocera ringtones] [http://www.easypayinfo.com/subscribe/tmp/qjpcdr.html tiger woods wife pic] [http://troniny.ovh.org/gallery/layout/edcfmm.html used motorcycle for sale in ma] [http://www.easypayinfo.com/subscribe/tmp/rfxlgb.html online adventure games for kids] [http://troniny.ovh.org/gallery/layout/reiwev.html in nature pattern] [http://www.olemissfans.com/chatpro/image/cgklkn.html vikings history pictures] [http://www.plurpage.com/classifieds/cache/okhhfe.html ms pac man arcade] [http://maps.my2gig.com/cache/wvahiv.html erotic audio and free download] [http://www.plurpage.com/classifieds/cache/hkoina.html kid programming] [http://2001.c3.hu/mas/tceqsf.html medal of honor videogame] [http://troniny.ovh.org/gallery/layout/bwnjen.html spanish school of riding] [http://www.housing.und.edu/reshalls/blog/wp-content/uploads/2007/04/img/umiuij.html discount ionamin] [http://www.stillwaterhomes.com/listings/images/pic/ecufsm.html arthur a levine books] [http://troniny.ovh.org/gallery/layout/noccfq.html nutrition kids] [http://www.systemsupport.und.edu/cache/avatars/emo/scaflm.html apartment northwest las vegas] [http://www.farmelco.hu/test/css/bcblgd.html eucation required for a crime scene investigator] [http://aura.c3.hu/thumb/lpppua.html placebo 20 years] [http://www.easypayinfo.com/subscribe/tmp/ijslwo.html second life last names] [http://www.lowell.edu/styles/old_style/css/wmnivr.html new york state public record] [http://informer.siam.edu/themes/hm/ujgvxd.html buy norvasc] [http://maps.my2gig.com/cache/okgpvt.html teens licking feet] [http://2001.c3.hu/mas/uhuhbn.html six security services] [http://www.stillwaterhomes.com/listings/images/pic/cqjflg.html 2 rpg stick super] [http://aura.c3.hu/thumb/thefew.html sweet blue days mp3] [http://www.farmelco.hu/test/css/abdgcx.html pat oscars restaurants] [http://informer.siam.edu/themes/hm/gdasvr.html order meridia] [http://www.systemsupport.und.edu/cache/avatars/emo/warbig.html buy ritalin] [http://ndr.hu/rhodes/upmuur.html rock river valley blood center] [http://www.plurpage.com/classifieds/cache/eatpaf.html american association of architect] [http://kristinlyseggen.com/gallery/1documentaries/7travel/ubaqae.html anal gallery interracial] [http://www.systemsupport.und.edu/cache/avatars/emo/hvvkfm.html arts and culture st johns] [http://www.olemissfans.com/chatpro/image/loiomb.html 2006 7 election march texas] [http://www.salona-yachts.eu/misc/oqmuhx.html ol football] [http://ndr.hu/rhodes/evrcii.html nyu masters finance] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/olqbmo.html add power url will] [http://kristinlyseggen.com/gallery/1documentaries/7travel/dhlkmj.html rocket modeler 2] [http://www.easypayinfo.com/subscribe/tmp/eugarp.html la freeways] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/qklego.html international freight forwarding uk] [http://troniny.ovh.org/gallery/layout/emodio.html research paper ideas in psychology] [http://ndr.hu/rhodes/vqvsfl.html tax accountant financial planner san diego] [http://www.stillwaterhomes.com/listings/images/pic/gncmeh.html precipitation forecast] [http://www.stillwaterhomes.com/listings/images/pic/nrjavm.html technique vehicle search] [http://troniny.ovh.org/gallery/layout/akximm.html atp i tennis tour] [http://www.stillwaterhomes.com/listings/images/pic/jabusw.html minnesota real estate closers] [http://www.housing.und.edu/reshalls/blog/wp-content/uploads/2007/04/img/rraddo.html buy effexor] [http://www.housing.und.edu/reshalls/blog/wp-content/uploads/2007/04/img/qemcvk.html download verizon wireless ringtones] [http://www.easypayinfo.com/subscribe/tmp/maeqsb.html i soci] [http://www.stillwaterhomes.com/listings/images/pic/gbnixf.html love your enemies jesus] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/oierwt.html attorney in denver co] [http://www.salona-yachts.eu/misc/koomeq.html porsche 911 turbo] [http://www.stillwaterhomes.com/listings/images/pic/evsgoq.html a 1 auto glass] [http://www.systemsupport.und.edu/cache/avatars/emo/bhpgbm.html ortho] [http://kom-pas.de/3xcms/config/hkatuploads/images/hugsdg.html kitchen cabinet door manufacturers] [http://2001.c3.hu/mas/kcstnl.html articulated] [http://www.easypayinfo.com/subscribe/tmp/cmxrrw.html office max printer] [http://activeimage.c3.hu/css/hchmxv.html lean lyric rock] [http://aura.c3.hu/thumb/vjsoap.html looking to price things after a fire] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/xorlfe.html mbk tuning] [http://www.plurpage.com/classifieds/cache/ulrsaa.html western blvd] [http://www.systemsupport.und.edu/cache/avatars/emo/ggngcl.html regional railroads] [http://activeimage.c3.hu/css/cvqfsg.html jenna bush hot pics] [http://aura.c3.hu/thumb/jcrsqr.html war destruction pictures] [http://troniny.ovh.org/gallery/layout/korabk.html mass transit magazines] [http://www.lowell.edu/styles/old_style/css/kenrfd.html download alltel ringtones] [http://www.easypayinfo.com/subscribe/tmp/gvfeic.html les droits des animaux]
+
==Simple==
[http://www.biblored.org.co/agenda_actividades/programas/images/opsxim.html tow ropes] [http://asie-voyages.com/upload/images/lens/ikdttb.html arkansas department human resource] [http://indianaoutfitters.com/s/info/tmp/awmwai.html wood pistol case] [http://smallbizbohol.com/democatalog/images/baner/kranom.html organ trail 2] [http://asie-voyages.com/upload/images/lens/jjwseg.html runway pics] [http://hoosierfishing.com/phpBB/images/avatars/avatar/clowvg.html paragraph symbol microsoft word] [http://xuccco.org/themes/AT-Green3/wveovd.html andamans and nicobar islands] [http://hoosierfishing.com/phpBB/images/avatars/avatar/vffdct.html rome free academy] [http://www.biblored.org.co/agenda_actividades/programas/images/qiubno.html marketing product mix] [http://tarsierfoundation.org/content/license/bnrqmb.html steel bands uk] [http://bluespringsbmx.com/4IMAGES/data/media/10/tmp/vnksis.html auto new car] [http://www.biblored.org.co/agenda_actividades/programas/images/rujvip.html line restroom] [http://ankelia-nature.com/catalogues/catalogues/pwmhtq.html superbowl celebrations] [http://xuccco.org/themes/AT-Green3/nhjjps.html was bedeutet das] [http://panties-pictures.com/free/lib/temp/tttlwo.html network monitors linux] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/fradft.html the zone diet reviews] [http://bluespringsbmx.com/4IMAGES/data/media/10/tmp/jnrnjb.html microsoft anti virus free downloads] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/cehtha.html elder estate real] [http://www.redacademica.edu.co/manejocorreo/Cliente/cache/jgbfxw.html kornakova photos] [http://tch-voyages.com/documents/prague/896/hjgcsm.html long term car hire usa] [http://www.lewakins.com/sr/images/cqkaim.html airway us visa] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/ossbsi.html auto gps review system] [http://www.norcab.com.au/joeavatiforum/templates/cache/wkvvvj.html intensity rainfall] [http://www.redacademica.edu.co/manejocorreo/Cliente/cache/qdbmtg.html lol lol lol lol] [http://indianaoutfitters.com/s/info/tmp/hptecu.html early head start program] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/xccldx.html metro card holders] [http://xuccco.org/themes/AT-Green3/mlrkrm.html pressure switch square d] [http://tarsierfoundation.org/content/license/bdmcsn.html picture moulding] [http://www.biblored.org.co/agenda_actividades/programas/images/evvwov.html aborigines government] [http://www.hdac.org/hdfaq/faq/nokhwc.html saudi family visa] [http://tch-voyages.com/documents/prague/896/hjkxmo.html register for data protection act] [http://bluespringsbmx.com/4IMAGES/data/media/10/tmp/puxqdq.html matt chapman video] [http://www.youthfitnesssolutions.com/FTP1/page9/bacgfk.html potter s wheel] [http://lumayagrealty.com/catalog/images/pics/cesjab.html johnson central high school] [http://tch-voyages.com/documents/prague/896/isebxk.html infant rash after fever] [http://lumayagrealty.com/catalog/images/pics/gjxnee.html safe gay sex] [http://talentmodeles.com/mannequin/images/cache/vxtrsk.html infant coughing] [http://lumayagrealty.com/catalog/images/pics/fneewj.html list of exits] [http://smallbizbohol.com/democatalog/images/baner/lwniqi.html problem repair window xp] [http://bluespringsbmx.com/4IMAGES/data/media/10/tmp/eiduji.html mouse pad material] [http://panties-pictures.com/free/lib/temp/mlprvg.html tv television troubleshooting] [http://www.norcab.com.au/joeavatiforum/templates/cache/nxdmcb.html excel privacy recovery] [http://bluespringsbmx.com/4IMAGES/data/media/10/tmp/uqoitk.html mexico people pictures] [http://panties-pictures.com/free/lib/temp/ftvpxq.html rn associate degree programs] [http://panties-pictures.com/free/lib/temp/iahqta.html preoperative care] [http://indianaoutfitters.com/s/info/tmp/tcikwo.html mp3 to car adapter] [http://www.lewakins.com/sr/images/ogistx.html mortgage lending companies] [http://indianaoutfitters.com/s/info/tmp/reqqbq.html medical manager sales] [http://hoosierfishing.com/phpBB/images/avatars/avatar/wtklpi.html poster motivation] [http://cvscaft-tcc.edu.ph/gallery/uploads/cache/abnati.html the simpson episode guide] [http://www.biblored.org.co/agenda_actividades/programas/images/goothv.html madrid centro] [http://bluespringsbmx.com/4IMAGES/data/media/10/tmp/pixdcb.html alemania] [http://smallbizbohol.com/democatalog/images/baner/gfifqn.html pregnant woman photos] [http://panties-pictures.com/free/lib/temp/awmfnv.html portable air conditioner electronic] [http://www.lewakins.com/sr/images/agshre.html yugoslavia constitution] [http://www.biblored.org.co/agenda_actividades/programas/images/blllok.html symptom of autism in adult] [http://bluespringsbmx.com/4IMAGES/data/media/10/tmp/bqlghi.html lyrics love me] [http://ankelia-nature.com/catalogues/catalogues/ncwasx.html shooting star video wrestling] [http://cvscaft-tcc.edu.ph/gallery/uploads/cache/kfkhdn.html jared campbell music] [http://panties-pictures.com/free/lib/temp/cfaoax.html speed pro performance parts] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/imqfkm.html recent sales real estate] [http://smallbizbohol.com/democatalog/images/baner/sqmvub.html as facilitator teacher] [http://tch-voyages.com/documents/prague/896/cdimim.html al gulf shore] [http://xuccco.org/themes/AT-Green3/hjwtrd.html accessory cell dimension pda phone] [http://www.youthfitnesssolutions.com/FTP1/page9/bltqvt.html time poems] [http://www.redacademica.edu.co/manejocorreo/Cliente/cache/hepnsv.html le musique de films de charlie] [http://hoosierfishing.com/phpBB/images/avatars/avatar/eeopul.html night club in pakistan] [http://roycemotor.com/carpics/cache/tpulno.html tradeshows for medical imaging] [http://panties-pictures.com/free/lib/temp/bgtfmc.html llama por favor] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/oubisg.html trailer park boy quote] [http://ankelia-nature.com/catalogues/catalogues/xihwvk.html tank less water heater] [http://tch-voyages.com/documents/prague/896/jixsuf.html extravaganza holiday] [http://roycemotor.com/carpics/cache/nmnblo.html end mortgage open] [http://www.lewakins.com/sr/images/jphcwh.html adobe premiere plugins] [http://asie-voyages.com/upload/images/lens/fgvpsf.html urbana schools] [http://www.norcab.com.au/joeavatiforum/templates/cache/qxunrx.html im singing in the rain] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/utsptd.html movie oliver twist] [http://cvscaft-tcc.edu.ph/gallery/uploads/cache/kkbcpn.html ibuprophen liver damage] [http://tch-voyages.com/documents/prague/896/wabwjv.html animal transportation zoo] [http://www.lewakins.com/sr/images/edxpje.html print shop 8] [http://smallbizbohol.com/democatalog/images/baner/wkasub.html masters of science in management] [http://bluespringsbmx.com/4IMAGES/data/media/10/tmp/vpsfjj.html off road chevy truck photo] [http://roycemotor.com/carpics/cache/fwavlq.html make a dry erase board] [http://lumayagrealty.com/catalog/images/pics/addsdo.html suck him dry] [http://www.biblored.org.co/agenda_actividades/programas/images/sqffmg.html refinancing auto loans bad credit] [http://www.redacademica.edu.co/manejocorreo/Cliente/cache/rdqdib.html traduire francais anglais] [http://indianaoutfitters.com/s/info/tmp/mhwvet.html music playing sites] [http://smallbizbohol.com/democatalog/images/baner/agshhq.html asian room designs] [http://www.norcab.com.au/joeavatiforum/templates/cache/kivohi.html mobile ultrasound business] [http://www.youthfitnesssolutions.com/FTP1/page9/ritldn.html register tape coupons] [http://indianaoutfitters.com/s/info/tmp/prbnio.html missouri college basketball schedule] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/lcfadk.html pressure switch square d] [http://www.sedbogota.edu.co/FINANCIERA/temp/tmp/wsuhps.html louisiana program recovery] [http://roycemotor.com/carpics/cache/eotdtq.html 2006 by draft nfl team] [http://roycemotor.com/carpics/cache/tohpwq.html window spider solitaire free download] [http://smallbizbohol.com/democatalog/images/baner/spxklr.html az corporation form] [http://asie-voyages.com/upload/images/lens/ofouut.html nintendo game boy advance sp cheat] [http://www.redacademica.edu.co/manejocorreo/Cliente/cache/svrppf.html optical laser disk] [http://roycemotor.com/carpics/cache/toudje.html lp field] [http://smallbizbohol.com/democatalog/images/baner/gacacw.html escrow agent software]
+
{{Flink|string|to_lower_case|string|desc=Converts all upper-case alphabetic characters to lower-case.}}
== Part  8 - String Handling Routines ==
+
{{Flink|string|to_upper_case|string|desc=Converts all lower-case alphabetic characters to upper-case.}}
<p><em>Under Construction</em></p>
+
{{Flink|string|to_url|location|desc=Returns the url which is accessed to visit the specified location.}}
<p><strong>void print( string helloworld )</strong><br>
+
{{Flink|int|extract_meat|string|desc=Returns the number of meat embedded in a string.}}
<strong>void echo( string helloworld )</strong><br>
+
{{Flink|int [item]|extract_items|desc=Parses a string for items and their amounts (handles plural & singular forms) and returns the results as a map.}}
Prints the given string to the graphical CLI window and to the status line of the main Adventuring window.</p>
+
{{Flink|int|length|string|desc=Returns the number of characters in the specified string.}}
<p><strong>string visit_url( string url )</strong><br>
+
{{Flink|string|char_at|string|index|desc=Returns the character at a specified index in a string.}}
Accesses the specified URL, manages any applicable redirects (including if the page offered a choice adventure), and returns the HTML of the final response page.</p>
+
{{Flink|string|substring|string|int|{{opt|int}}|desc=Returns the substring of the specified string, starting from a specified position, and optionally ending before a specified position (defaults to remainder of string).}}
<p><strong>string location_to_url( location place )</strong><br>
+
{{Flink|buffer|replace_string|buffer|string|string}}
 +
{{Flink|buffer|replace_string|string|string|string|desc=Replaces all text in the first string that matches the second with the third.}}
 +
{{Flink|buffer|replace|buffer|int|int|string|desc=Replaces all text from the first index to the second index with the supplied string.}}
 +
{{Flink|string|url_encode|string|desc=Converts a string into a URL formatted string.}}
 +
{{Flink|string|url_decode|string|desc=Converts a URL formatted string into regular text.}}
 +
{{Flink|string [int]|split_string|string|{{opt|string}}|desc=Splits apart the first string at line-breaks or using an optionally supplied delimeter and returns an integer-keyed map of the result.}}
 +
{{Flink|string [int]|session_logs|{{opt|string}}|int|desc=Gives access to sessions logs. And stuff. [http://kolmafia.us/showthread.php?t=573]}}
 +
{{Flink|buffer|append|buffer|string|desc=Appends the string to the end of the buffer.}}
 +
{{Flink|void|set_length|buffer|int|desc=Changes the length of a buffer.}}
 +
{{Flink|buffer|delete|buffer|int|int|desc=Deletes the specified portion of the buffer.}}
 +
{{Flink|buffer|insert|buffer|int|string|desc=Inserts the string at the specified point in the buffer.}}
 +
==Substring Search==
 +
{{FunctionEmbed|contains_text|format=signature|desc=yes}}
 +
{{FunctionEmbed|ends_with|format=signature|desc=yes}}
 +
{{FunctionEmbed|index_of|format=signature|desc=yes}}
 +
{{FunctionEmbed|last_index_of|format=signature|desc=yes}}
 +
{{FunctionEmbed|starts_with|format=signature|desc=yes}}
  
Returns the URL that would need to be accessed to visit the specified location.</p>
+
==Regular Expressions==
<p><strong>boolean contains_text( string source, string query )</strong><br>
+
It is advised that anyone desiring to use these functions should first understand the basics of [[Regular Expressions]] and how these functions implement that language.
Reveals if the query string is a substring of the source string.</p>
 
<p><strong>int extract_meat( string text )</strong><br>
 
Returns the amount of meat contained in a string passed to it in integer format. For use in k-mail parsing. *Not for use on pending trades.*</p>
 
<p><strong>int [item] extract_items( string text )</strong><br>
 
takes the text you have provided and parses it for any items that KoLmafia would have found normally.  This means you have access to the built-in pluralization handler as well as the ability to NOT have to lookup description IDs or whatever other loops you had to use to access that information. For use in k-mail parsing. *Not for use on pending trades.*</p>
 
<p><strong>int length( string text )</strong><br>
 
Returns the length of the given string.</p>
 
  
<p><strong>int index_of( string source, string search )</strong><br>
+
{{Flink|matcher|create_matcher|string|string|desc=Creates a matcher from a pattern and input string.}}
Returns the first index of a given substring in a string.<br>
+
{{Flink|matcher|reset|matcher|{{opt|string}}|desc=Resets matcher to search from beginning of string, possibly with new input.}}
<strong>int index_of( string source, string search, int start )</strong><br>
+
{{Flink|int|group_count|matcher|desc=Returns the number of capturing groups in the pattern.}}
Returns the next index of a given substring in a string starting from the given position.<br>
+
{{Flink|string [int,int]|group_string|string|string|desc=Maps a string to an aggregate (see page for details). [http://kolmafia.us/showthread.php?t=318]}}
<strong>int last_index_of( string source, string search )</strong><br>
+
{{Flink|int|start|matcher|{{opt|int}}|desc=Returns the starting index of the previous or specified capturing group.}}
Returns the last index of a given substring in a string.</p>
+
{{Flink|int|end|matcher|{{opt|int}}|desc=Returns the ending index of the previous or specified capturing group plus 1.}}
<p><strong>string substring( string source, int startfrom )</strong><br>
+
{{Flink|boolean|find|matcher|desc=Finds the next instance of the pattern or returns false if no more matches exist.}}
Returns the substring of the given string starting from the given character position in the string, and ending at the last character.<br>
+
{{Flink|string|group|matcher|{{opt|int}}|desc=Returns the contents of an indicated capturing group (starting at 1) or the entire pattern if not indicated.}}
<strong>string substring( string source, int start, int end )</strong><br>
+
{{Flink|string|replace_all|matcher|string|desc=Replaces all pattern matches with a given string.}}
 +
{{Flink|string|replace_first|matcher|string|desc=Replaces the first pattern match with a given string.}}
 +
{{Flink|buffer|append_replacement|matcher|buffer|string}}
 +
{{Flink|buffer|append_tail|matcher|buffer|desc=Appends the text returned by a matcher to the end of the buffer.}}
  
Returns the substring of the given string starting from the character position indicated by start in the string, and ending at the character position indicated by end.</p>
+
[[Category:Scripting]]
<p><strong>string replace_string( string source, string search, string replace )</strong><br>
 
searches the source string for the search string and replaces all instances with the replace string</p>
 
<p><strong>string url_encode( string text )</strong><br>
 
<strong>string url_decode( string text )</strong><br>
 
Converts a string text into a formatted string for using with raw URLs or from a formatted string back into “normal” text.</p>
 
 
 
<p><strong>string [int] split_string( string source )</strong><br>
 
Returns a map of strings which is the passed string split into individual lines. Originally implemented for use when parsing session logs, but may see more uses in the future.
 
http://kolmafia.us/index.php/topic,794.msg3868.html#msg3868 <br>
 
<strong>string [int] split_string( string source, string regex )</strong><br>
 
<strong>string [int,int] group_string( string source, string regex )</strong><br>
 
see this post located on the script repository for more information:  http://kolmafia.us/index.php/topic,451.msg2235.html#msg2235 </p>
 
 
 
<strong>string [int] session_logs( string player, int day_count )</strong>
 
Gives access to the session logs saved by kolmafia. More details will be added when this function's own page is written. For now, more extensive details can be found here: http://kolmafia.us/index.php/topic,794.msg3879.html#msg3879
 

Latest revision as of 12:43, 23 December 2020

Simple

string to_lower_case( string )

Converts all upper-case alphabetic characters to lower-case.

string to_upper_case( string )

Converts all lower-case alphabetic characters to upper-case.

string to_url( location )

Returns the url which is accessed to visit the specified location.

int extract_meat( string )

Returns the number of meat embedded in a string.

int [item] extract_items()

Parses a string for items and their amounts (handles plural & singular forms) and returns the results as a map.

int length( string )

Returns the number of characters in the specified string.

string char_at( string, index )

Returns the character at a specified index in a string.

string substring( string, int, [int] )

Returns the substring of the specified string, starting from a specified position, and optionally ending before a specified position (defaults to remainder of string).

buffer replace_string( buffer, string, string )

buffer replace_string( string, string, string )

Replaces all text in the first string that matches the second with the third.

buffer replace( buffer, int, int, string )

Replaces all text from the first index to the second index with the supplied string.

string url_encode( string )

Converts a string into a URL formatted string.

string url_decode( string )

Converts a URL formatted string into regular text.

string [int] split_string( string, [string] )

Splits apart the first string at line-breaks or using an optionally supplied delimeter and returns an integer-keyed map of the result.

string [int] session_logs( [string], int )

Gives access to sessions logs. And stuff. [1]

buffer append( buffer, string )

Appends the string to the end of the buffer.

void set_length( buffer, int )

Changes the length of a buffer.

buffer delete( buffer, int, int )

Deletes the specified portion of the buffer.

buffer insert( buffer, int, string )

Inserts the string at the specified point in the buffer.

Substring Search

boolean contains_textstring, string )

Returns true if the first string contains the second string.

boolean ends_withstring, string )

Checks whether a string ends with a suffix string. (case-sensitive)

int index_ofstring, string, int? )

Returns the position of the second string in the first (or -1 if not found), optionally starting its search from a given position.

int last_index_ofstring, string, int? )

Returns the last index of the second string in the first, or -1 if no match is found.

boolean starts_withstring, string )

Checks whether a string starts with a prefix string. (case-sensitive)

Regular Expressions

It is advised that anyone desiring to use these functions should first understand the basics of Regular Expressions and how these functions implement that language.

matcher create_matcher( string, string )

Creates a matcher from a pattern and input string.

matcher reset( matcher, [string] )

Resets matcher to search from beginning of string, possibly with new input.

int group_count( matcher )

Returns the number of capturing groups in the pattern.

string [int,int] group_string( string, string )

Maps a string to an aggregate (see page for details). [2]

int start( matcher, [int] )

Returns the starting index of the previous or specified capturing group.

int end( matcher, [int] )

Returns the ending index of the previous or specified capturing group plus 1.

boolean find( matcher )

Finds the next instance of the pattern or returns false if no more matches exist.

string group( matcher, [int] )

Returns the contents of an indicated capturing group (starting at 1) or the entire pattern if not indicated.

string replace_all( matcher, string )

Replaces all pattern matches with a given string.

string replace_first( matcher, string )

Replaces the first pattern match with a given string.

buffer append_replacement( matcher, buffer, string )

buffer append_tail( matcher, buffer )

Appends the text returned by a matcher to the end of the buffer.