Talk:String Handling Routines

From Kolmafia
Revision as of 03:01, 24 October 2007 by 203.88.192.104 (talk)
Jump to navigation Jump to search

pt cruiser 22 www cislscuola lombardia it uomo in casa orsi gay shandi audi a3 130 jail bird man esopo cucina a legna festa a hollywood per xbox live ca phe thanh da grundig satellit unnao quark xpress 6 patch monitor 17 sony s walter tobagi km 0 tv 185 modica it auto lexus www alldatazz com dpi tavolette grafiche takie czarne oczy gorilla nebbia ostrica pedali ciclismo longwood acer 1600 ludwig van beethoven piano concertos n 2 4 camera savona rischioso inganno chario premium get tangled up in me win mx in itaiano conoscere ragazza russa robbie williams music box biographical collection televisori lcd philips pixel plus 2 www goglee om kthd530 512 www marinamilitare it oroscopo settimanale huey p newton wireless bridge dudinka ich liebe deutsche land nord sud ovest etro uomo yentai fotografa rony size nen jiang backstreet boys dvd murolo roberto safri duo all the people in the world in vacanza da una vita canciones de avril lavigne la boutique della casa biglietti falsi vasco epson c62 cartuccia ragazza giapponesi gratis frigoriferi rex rd 20 s mani di fata it aiwa radio sistema solare katia nuda del grande fratello santa fe hotel capitan kidd adidas adi racer low exilim z40 schede madri amd dfi profumi maschili wright basil testo di magica la notte caps serena grandi transceiver aui rj 45 raccoglitori a 3 anelli big air pian dei cortini vernale elda locatelli fotografia de mujeres negras de africa siemens s 440 missa nissan ravenna orchstra far cry soluzione stajl www folha com sanaga haute freud prodotti punte seghe ecommerce shopping cart vanbasco s karaoke player hp centrino 1 5ghz vivavoce panasonic scuola danza classica torino tomtom go mappe karlfeldt erik axel server stampa canon 580 mi ritorni in mente rsmmc per nokia 6680 i prova scritta esame di stato olympus camedia c 360 zoom geforce ultra sli bilbana pc dekstop hotel a rovaniemi consumption junction bmw k 1100 giornale la sicilia spartiti dei led zeppelin mtc calendario 2006 francesco arca entra subito studio mediasuite s 40 bruciore piede sinistro notizia e media ragazzo bello foto get out jojo noce moscata vocabolario cinese albergo economici atene mezzogiorno e mezzo di fuoco amore psiche software mac ricetta tarallo auto cross annuncio telefono to name ai manga porno gratuiti photos 2pac midland 18 gods esercitazioni di analisi matematica 1 pre pagato mobile il libraccio nomadi del canto foto annuncio coppia heil tweeter assicurazione modena faenza bajar musica regueton infradito sundek stcc driver motorola c450 athlon 64 3200 venice tray immagini festa della mamma brigantino nino besozzi la strada del crimine opere di salvatore quasimodo tiki thong alice oggi il gladiatore 2 hp cavo alimentazione inferno a caracas baraldi block filter menopon gallinae www rey com historia del basket daewoo dhc x100e stampe colorate slot macchina slot borgaro telefono cellulare gamberetti tartarughe www petia ru pan store novara hotel download free video e io mi gioco la bambina ministero delle politiche agricole e for biglietto aereo bilbao dvd key ivrylabataille hoppa hoppa reiter parla piu piano lyrics riprese heinrich nudi a cavallo mirc chat montaggio a secco televisione lcd 19 pollici kia carens 20 gurgaon testo di dragostea din tei ht1000 videoproiettori per amore di poppea caldaie vai gianna freccia rainbow miles ogliastra servizi marittimi futurama xxx toscana hotel saturnia gold minar sex miss ibm 1334 ragazze di campagna l e luci di natale pezzali dio come te amo 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.