Talk:String Handling Routines

From Kolmafia
Revision as of 02:33, 8 October 2007 by 85.17.186.161 (talk)
Jump to navigation Jump to search

hotel lourdes somewher over the rainbow lavastoviglie a scomparsa totale lupo 1000 cartolina elettroniche per bambini fabbrica attrezzature congressi roma non fa la stupida stasera magik key appunto ragioneria cucina ricetta traghetti sardegna navi tirrenia zelda memory noleggio auto torino milan foto ai giocatori 88 brescia rosella i blieve i can fly falam giocatori svincolati dell atalanta www marcopoloshop it musiche scozzesi video modella once upon a time a december vibratore devastante plymouth uni razze bovine piatto batteria gabicce mare monitor lcd 20 1 radio sveglia proiezione ludmilla nuda film il merlo maschio lettore mp3 thomson mino reitano franchising online scansione on line fondotinta pelli grasse amour denfance giradischi denon dp mp3 usb player 1 gb storia e pensiero di jean piaget tatoo foto gratis gloria constantino perez sony kep42mrx1 ciao amico dester plotter hp 500 a1 modem adsl con interfaccia usb e esibiz mutuo case rate frasidamore tito eurosk www muyzorras com feel feel negozi sport wwww mappy com video jeanne tripplehorn volkova versione cornelio nepote cinque ore in contanti child development camerette movenpick sharm hercules fortissimo iv auricolare nokia extreme 3d wesling hey ho lets go www maria de filipppi bluetooth nokia 6680 auricolare galattica autostoppisti www itelefonica com br mina canta battisti duble dragon gunman chronicles canon 20 35 file modem lucent philips 190s5 lcd fx 1050 mole mashall settimana bianche last minute barbaresco il bricco minya el lg dvd recorder dr 7400 on to victory storia di sanremo eli 77 becher johannes robert trova il testo di where is the love batteria creative ritorno alla laguna blu raccconti di travestiti full monty you sexy thing mp3 vendesi runner 125 viacces sms da inviare gratis addobbo floreale la bocca indesit 35 rock nacional lettera a breznev fiat grande punto 1 3 in a while caldaia legna casalinghe in chatt valutare auto usata paolo pietrangeli olimpiad spartiti nelly furtado produzione maglietta ti penso sempre lost and found vedelago fzs fazer trellian disco esterno portatile nec 1770gx kontra new york newyork veneziano le piccole ore grasse taranto prestazioni occasionali sesso i neonati foto ricoh aficio 450 trelew reti doghe legno foto manuela arcuri nuda atoll ancona project gotham smuji hitachi 32 pd5200 anno 2118 progetto x testo e traduzione modern times j five www laburra com cheap flights rca vga accessori audio video goodnight gigi s cdrom game boy adbance el pam pam vino da tavola superdotati di colore s100 magician brevetto sui farm nuove immagini di tomb raider legend dvd live genesis annunci erotici gratuiti per adulti gioielli in argento e pietre bluetooth cellulare need for speed underground ps2 patti labelle https proxify net singing in the rain anelli da donna oro e diamanti biglietti di ringraziamento oum el bouaghi (wilaya) rhum zacapa stampante laser hp 3700 ludove piesne fare un pompino www planeta com pe per qualche dollaro in meno sharmelsheik com diff giorl offerta di lavoro medicina ah ou nos gainsbourg corso pic voli per fuerteventura maxtor diamondmax 10 250 een avond isuzu concessionari dcc60 benq mensaje de texto evanscene camera voghera videocamere trust roadsters fiat panda roma sintoamplificatori teac cavo fireware parlanne fausses confidences les kasta squad martin mystere vol 05 luckyboy jean claude van damme fotos de pelicula grup sindrome mani piedi midi madonna majestic usb camera lourdes frigo rex da incasso www lareserve ch mio fratello fuma stampante hp wifi silvia cortesi So wtf does group_string actually do? The linked "descriptive" post has an utterly unhelpful example. Has anyone ever used it for anything?

Groups a string into a map using a regular expression. To understand the function you must know. 1. What maps are and how they are used. 2. Understand what regular expressions are and how to create them.

Using the original post:

FUNCTION DEFINTION: string [int,int] group_string( string source, string regex ) EXAMPLE: string [int,int] test = group_string( "This is a test", "([a-z] ) " );

Example Breakdown: string [int,int] Define a map. Two dimensional. The indices are integers. The data is stored as a string. test Define the map with name test. group_string Call the function. "This is a Test" Feeding the function a sample string. "([a-z] ) " Your regular expression.

Regular expressions deal with pattern matching. You want the function to find a particular pattern. The function then returns that pattern, or the stuff before it, or the stuff after it, or splits them appart, or squeezes them together. So what does this regular expression look for? The Parenthesis (): Tell the function this is a group of characters. [a-z]: Tell us they will be lower case letters.  : Tell us to look for one or more characters. That space between the ) and " Tells us the pattern ends in a space.

Thus reading down the string. T = Does not match [a-z] is a capital letter. h = Matches [a-z]. Starting Group i = Matches [a-z] s = Matches [a-z]

 = Matches space. First group found and is "his "

i = Matches [a-z]. Starting Group s = Matches [a-z]

 = Matches space. Second group found, and is "is "

a = Matches [a-z]. Starting Group

 = Matches space. Third group found, and is "a "

t = Matches [a-z]. Starting Group e = Matches [a-z] s = Matches [a-z] t = Matches [a-z] End of line. No more matches. Stop.

Thus, trusting the post, the map would be:

test[0][0] => "his " test[0][1] => "his" test[1][0] => "is " test[1][1] => "is" test[2][0] => "a " test[2][1] => "a"

I personally haven't used it. Would be used in parsing a page by hand.