Talk:String Handling Routines

From Kolmafia
Revision as of 12:36, 23 September 2007 by 60.218.98.94 (talk)
Jump to navigation Jump to search

teen free rider tomtom navigatori gps goldenberg britisch nadia parl ragazzo trieste gioco pc recensione lonsdale giubbino dj verona bambole da collezione vendo abbigliamento usato in firenze boby mc ferin fata maria incontri amatoriali gratis aureon 7 1 muro video decapitazione giapponese monete italia repubblica serie stampanti 10 15 gli appuntamenti nintendo per il nuovo anno la ginestra jeans diesel 30 maglioni iceberg buscar en escolar con linea porno gay un giorno forse donna sotto le stelle chacker davite delucchi snc mercedes c sw mogli calciatori russi telefonini umts vodafone los suaves corvo torvo cheryl www hotelparadiso ags (tecnica) macchina caffe ariete florence pavimenti e rivestimenti la bestia nello spazio clouds above gianfranco ferre donna la via maestra negrita rotolando ef 70200mm f 2 8l is usm mario winans testo i don t wanna know amplificatori vintage prefabbricato sicilia trucchi giochi xbox prade antonio metri il calendario sexi di paola perego del 2 foto racconti incesti sales manager (regione lombardia lecco provincia) ufficio entrata kiss dvd player dp1000 hammer nicky yam black decker smerigliatrice anniversary gift k 550 vacanze ottobre un po di storia dei beatles nvidia geforce 6200 256 mb agp giovanna arco fleming photos colocataires m6 logitech tastiera dragonstea tin dei auto noleggio vigevano scandalo croazia hyundai atos 1999 netbus pro 2 0 gioco euro readers 2004 motori di ricrca fz 97 p 1 ix il libro degli inventari un tipo straordinario matures very large telescope tu no dei gemelli diversi forni termozeta james daly versace gonne zou zou nike calcetto pace vapor racconti sesso violento gazettino pietre www ebayl it taedong stampanti oki led andamento obbligazione baraonda latina laserjet 2840aio ogg the sims baustelle love affair nur sas palle al balzo francisca kuck cerca bull mtaa 4511 lampada di emergenza microsoft office ita shantung madalina manole laserjet 1500 lettore registratore dvd vhs claudia koll in cosi fan tutte fiat pd macchina cucito www oficina g3 com br microsoft sasser (af) worm removal tool midis perreo gratis donne in cerca di sesso foto donna it psp italia dibujos tridimensionales motorola hs810 dx50 divx el debate de culiacan trio ct01 laurence harvey it s good be in love notebook toshiba sa60 annuncio coppia molise beastie boys video antology estrazione lott appunto microbiologia lisa gerrard sacrifice formato a2 stampanti campi e onde nell elettronica liberatoria per foto www formaper com xuandu viaccess2 la tigre del sesso mediterraneo colonna sonora film link popularity concessionari tributi italia sardegna vacanze in schede video nvidia 6800 gt mobilni telefoni bracciale topazio argento siddharta hesse culture per la comunicazione peruta i like it loud asus a716 cavo auto www ilpalermocalcio it gogli com colle genova videocamere 0 abit ic7 lettore dvd divx dvdp244 divisa marina militare belkin wireless pcmcia immagini jpg cercando l oro plotter hp designjet a1 gumbao modem fax esterno us robotics american conquest vlaska muzika rolex daytona sesso matto aculaser 1100 toner atlante zanichelli storico exe olympus miu negozi motori showgirl italiana varia d f dieta di brad pitt hotel firenze albergo firenze isa proxy server donne sicilia geforce go 6 vola lingeries pantaloni 40 you love a woman sagre ciliegia side by silver prestito artigiani diffusori canton sced up correre passat variant 2 5 tdi ode al vino pablo neruda forza nelly furtado ridder lettori mp3 lg ibm 1354 commisione esami di maturita midi antoine la tramontana rum zacapa vivaldi la notte cisl modena processori intel dualcore extreme inciclopedia arianna facciolini 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.