Talk:String Handling Routines

From Kolmafia
Revision as of 03:05, 7 November 2007 by 158.232.241.4 (talk)
Jump to navigation Jump to search

employee recruitment video ac drive europe in market report research quick fix loan paycheck advance express payday loan diapers medical terminology chronoswiss watch away message quotes trim kid asian babes wholesale floating candle years of college down the drain california colleges audit program for employee benefit wheels and tires janitorial supplies cherry almond credit counselors airport logan map free forex online training video ken mar mini choppers i heard em say lyrics simpson international calling card lay down with me tell me no lies lyrics verizon wireless account alturas lescol picture of split rock light house freescreensaver free cell phone ringtones i love you art pictures employment in san antonio texas music used in movie aol free virus protection sexual love quizzes sexy young girl pics kelley blue book used car price lcd monitor meant each virtual server service pack alligator florida photo philips mp3 abbeys add com port to windows xp party sex galleries san andreas cheats and codes for xbox lottery 1920s silent movies today is the day song clonidine vicerex can crusher whole life health tow truck chicago playing music on psp inland homes what is java programming rj safety adaware se professional serial mba letter of recommendation humulin n insulin monopoly 3 activation code clitoris orgasm artist music news hall rental planet of lust iq scales pagination code i dont know how to love him midi retailer of the year old spanish movies andrew k fletcher standard weights and measurements walt disneys animation entertainment top italian restaurants in philadelphia video of chicken little cheapest airfares philips bulbs wisconsin driver test insert html email image office automation equipments upper respiratory infections suncom wireless landing pier point hugo boss what is latitude and longitude new album releases for 2005 the dead case password credit card companies pictures of french maids the earth and its people 3rd edition a labeled fish www western union money transfer salon reception desk knit tops tees sram chains waterloo mall littleboys pumping partys something for a laugh orgias anal designer dress sale wedding ask jeeves woods hole research centre the kitty litter audit income tax spyware download accessory camera digital hp vt boston college psychological and emotional health anty playboy bunny layouts poison band photos wells fargo stock purchase plan fucking pregnant abuse women quixtar party porn swinger metodos de aprendizaje horny house wives steven tyler man over 55 david bisbal saint john maps tattoos sexual enhancement magic jumps beef jerky skelaxin online electric scooter sale japanese movie nurse porn metal roof insulation sleep apnea symptoms treatment irish dancing birmingham health and safety paul smith watch air travel last minute deal dv in out stacy london rambo ii chaussures crystal carlson arizona softball schedule wooden handles for fan egypt land area nissan skyline models priceless motorola blue tooth headset manual jimny suzuki 350ml true love game nude katie holmes calcium male black gay man ar15 ici deluxe paint in from the storm send me spam amway water and power credit adobe reader 60 free download podcast radio stations grits and eggs ringtones com perspectives makeup timeshare apartments for sell italy elevator co ltd amp meter dc magazine remix social security district offices motorway maps england printers mc callum house mangosteen for sinus problems radio station business news iowa cheap printer bigtit guardian generators rv att conference call set up beautiful arab girls emirates airline free movie xxx chronic alcoholism rhianna i remember you lyric game cartoon crosscheck squirt movies email marketing software spice one kind words for children web cams psychedelic band posters longevity information buy pharmacy online mechanism of antibiotic resistance stripe shirt guy at the end of saw 2 birthday games stripper 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.