test

Run Settings
LanguageRaku
Language Version
Run Command
# say 'Hello World!'; # my $name = 'John Doe'; # say 'Hello $name'; # say "Hello $name"; # my %capitals = 'UK', 'London', 'Germany', 'Berlin'; # say %capitals; # say "fotbar" ~~ / <!after foo> bar /; # OUTPUT: «bar␤» # say "foobar" ~~ / <?after foo> bar /; # OUTPUT: «bar␤» my @tracks = ( "TRMMMNS128F93548E1<SEP>SOYGNWH12AB018191E<SEP>3 Gars Su'l Sofa<SEP>L'antarctique", "TRMMMPJ128F9306985<SEP>SOQMZZI12AB01850D4<SEP>Christian Castro<SEP>Tu Vida Con La Mía", "TRMMMKQ128F92EBCB5<SEP>SOOLRHW12A8C142643<SEP>Kreator<SEP>All of the same blood", "TRMMMHS128F42A0971<SEP>SOMXBRA12AB017C656<SEP>The Emotions<SEP>Blessed", "TRMMWJS12903CBB7F5<SEP>SOLBDWO12AB0188CC2<SEP>Aerosmith<SEP>Remember (Walking In The Sand)" ); my @tracks2 = ( "TRMCFLR128F92F34FC<SEP>SOXBSOF12A8C1436AE<SEP>Full Flava<SEP>Rescue Me (Taste Of Flava Remix) (feat Hazel Fernandes)", "TRNHWIZ128F93164A0<SEP>SOCESGY12AB018543C<SEP>Neil Young<SEP>Ive Been Waiting For You [Previously Unreleased Mix]", "TRMUDCR12903CA7BAA<SEP>SOJBAOJ12A8AE47999<SEP>Franky Pank<SEP>Filet Mignon \{Doomsday\}", "TRNGBKC12903CE5953<SEP>SOBJIRH12AB018BF53<SEP>Atahualpa Yupanqui<SEP>Ahí Andamos\\ Señor", "TRFIOAR128F93153DC<SEP>SOCTJMJ12AB0185CDA<SEP>Sonny Terry / Brownie McGhee<SEP>Understand / Me", "TRMUDCR12903CA7ADF<SEP>SOJBAOJ12A8AE47050<SEP>Frank Sinatra<SEP>Strangers In The_Night (Remastered Album Version) [The Frank Sinatra Collection]", "TRMMGQU128F9340803<SEP>SOLTFTE12A8C13718B<SEP>Paul Miller<SEP>Memories Of Love - Original Mix", "TRNGBMI128F4253718<SEP>SOJPIVB12A8C13302F<SEP>Illuminate<SEP>Outro: \"Alles_ Was Blieb", "TRNGVLK12903CC942B<SEP>SOFFWQH12AB018C366<SEP>Sturm Café<SEP>Sturm Café \"Der Löwe Ist Zuruck", "TRNCYSN128F9300977<SEP>SOVHMDW12AB017E669<SEP>Jimmy Burns<SEP>Baby Don`t Do It", "TRNRYSZ128F425806B<SEP>SOPTQQY12A8AE4717E<SEP>Victims Family<SEP>Vinnie + 1", "TRNQNWN128F932E118<SEP>SOUUWRZ12AB0188A67<SEP>Under The Drone<SEP>Waste = Burn / Beauty", "TRNQDIN128F9302583<SEP>SOGNLSX12AAF3B145B<SEP>K3 Feat. Alice Lascelles<SEP>Play To Win feat. Wesley S Remix", "TRMQWOS128F42AE007<SEP>SOBWHYN12A8C13DB4F<SEP>Anthony Hamilton<SEP>Preacher's Daughter featuring Tarsha McMillian", "TRMUDCR12903CA7ADF<SEP>SOJBAOJ12A8AE47050<SEP>Frank Sinatra<SEP>Strangers In The Night (Remastered Album Version) [The Frank Sinatra Collection]", "TRNGCCE128F4215E1B<SEP>SOXZKUO12A6D4FC481<SEP>John Brown\'s Body<SEP>Blazing's Love" ); my @tracks3 = ( "TRMMHSX128F92D8F4D<SEP>SOYKXMF12A58A79AE4<SEP>Asheru And Blue Black Of The Unspoken Heard<SEP>How You Livin? f/J-Live & Grap Luva & Sondia", "TRHGJIW128F421CBA7<SEP>SOQRZSW12A6D4FEBFB<SEP>Sexappeal<SEP>¿Por Que No Dejas Ese Loco?", "TRMWVCV128F9344EF0<SEP>SOTJHZJ12AB0182F54<SEP>None More Black<SEP>You Suck! But Your Peanut Butter's OK", "TRRCOCB128F42689D2<SEP>SOAGUFA12A8AE478DA<SEP>Héroes del Silencio<SEP>¡ Rueda_ Fortuna ! (Live Version 1995)", "TRMMHMD128F427428D<SEP>SOPWMAB12A58A7E8E9<SEP>Blue Foundation<SEP>02.17 AM", "TRMHGSI128F4272C6C<SEP>SOPAFYQ12A8C13500E<SEP>Marvin Hamlisch;John Lithgow;Jeffrey Huard<SEP>I ;Cannot ;Hear the City (Jack Noseworthy with Marvin Hamlisch at the piano)", "TRMMUOV128F14550D0<SEP>SOYOOFW12A6D4F859A<SEP>Endellion String Quartet<SEP>String Quartet No.3 in D major Op.18 No.3 : I Allegro", "TRMMJXM128F4250CBA<SEP>SOLUYOV12AF72A655B<SEP>Eric B. & Rakim<SEP>Set 'E&m Straight", "TRMEGTF128F4216F47<SEP>SONOMZJ12A6D4FB39D<SEP>Sole<SEP>Da Year ov Da \$exxx Symbl (Vocal)", "TRMIWTC12903CF9ED9<SEP>SOYSLAJ12A58A789EC<SEP>Consequence<SEP>Wack N*ggas", "TRMMDSM128F9301C01<SEP>SONYDXG12AB017EF87<SEP>Tonex<SEP>F@ce Down", "TRMXSDC128F427AF0E<SEP>SOUYOAK12A8C136985<SEP>Williamson<SEP>2%er", "TRMKVMA12903CA3C66<SEP>SORRWZX12AB01884A6<SEP>The Beautiful People<SEP>Sleepless Nights #2", "TRPKKCH128F427478C<SEP>SOKGPHO12A8C13A896<SEP>Reginald Dixon<SEP>Irish Washerwoman | Peggy O'Neill | The Rose Of Tralee | Killarney | St patrick's day", "TRMMRNI128EF34C4A7<SEP>SOUOLRQ12A6BD5074E<SEP>Elakelaiset<SEP>Humppakavalier" ); my @tracks4_7 = ( " ' Quik's Groove VII ' ", "' Burn 'Em Down '", "Truck Drivin' man '", "' ll B'e Back", " Show Me' The Way ", "Hel_lo9 'World", "Hello9 'World" ); my @tracks8 = ( "King OF tHe hill", "outstanding 'of the with", "no where to hide", "to !my dear with" ); # for @tracks -> $track { # ################ # # LAB 1 TASK 1 # # ################ # ## Edit the regex below to capture only song title # ## # say $track; # my $song_title = /\<SEP\> .* \<SEP\> .* \<SEP\> (.*)/; # # my $song_title = rx/^ SEP !(?before .*SEP) .* $/; # if ($track ~~ $song_title) { # say $0; # ## # ############################# End Task 1 # # $0 should be the title caught by regex first set of parens # # It is added to end of the array # # @tracktitles.push: $0; # } # say "\n"; # } ######Task 2######################################################################### # my $str = "TRMMWJS12903CBB7F5<SEP>SOLBDWO12AB0188CC2<SEP>Aerosmith<SEP>Remember (Walking In The Sand)" # $str ~~ s/W/K/; # say $str; # $_ = 'The Replacements'; # my $substitution = s/Replace/Entrap/; # # s/Replace/Entrap/; # # .say; # OUTPUT: «The Entrapments␤» # $_ ~~ $substitution; # say $_; # # This loops through each track # for @tracks2 -> $title { # ########################## # # LAB 1 TASK 2 # # ########################## # ## Add regex substitutions to remove superflous comments and all that follows them # ## Assign to $_ with smartmatcher (~~) # ########################## # say $title; # $_ = $title; # my $song_title = /\<SEP\> .* \<SEP\> .* \<SEP\> (.*)/; # $_ ~~ $song_title; # $_ = $0; # say $_; # # Uncomment and replace ... with a substition for ( and anything that follows # $_ ~~ s/<[\( \[ \{ \\ \/ _ \- : \" ` \+ =]>.*//; # say $_; # # Repeat for the other symbols # $_ ~~ s/feat\. .*//; # say $_; # say "\n"; # ########################## End Task 2 # # Add the edited $title to the new array of titles # # @filteredtitles.push: $_; # } ############################################################################## # my $string = "This is a #test string."; # say $string; # $string = $string.subst('#', 'HASH'); # say $string; # Output: This is a HASHtest string. ########################## # LAB 1 TASK 3 # ########################## ## Add regex substitutions to remove punctuation ## Remember to permit the apostrophe ' (near enter key) ## Use the g (global) directive ########################## # for @tracks3 -> $title { # ########################## # say $title; # $_ = $title; # # Uncomment and replace ... with a substition for ? # $_ ~~ s:g/<[ \? \x[00BF] ! \x[00A1] \. ; : & \$ \* @ % \x[0023] \|]>//; # say $_; # # Repeat for the other symbols # # my $hash = /#/; # # $_ = $_.subst('#'); # # $ ~~ s:g/$hash//; # # say $_; # say "\n"; # ########################## End Task 3 # # Add the edited $title to the new array of titles # # @filteredtitles.push: $_; # } ################################################################################ # my $string = "''' Hello 'World! '''"; # say $string; # $string ~~ s:g/^ \'+//; # $string ~~ s:g/\'+ $//; # say $string; # Output: "Hello World!" # $string ~~ s:g/^ \s+//; # $string ~~ s:g/\s+ $//; # say $string; # my $string ="Hello9 'World"; # should return False # # my $string ="Hel_lo9 'World"; # should return True # # my $pattern = /<-[\w\s\']>/; # my $pattern = /<-[a..zA..Z\d\s\']>/; # say so $string ~~ $pattern; # if ($string ~~ $pattern) { # say 'yes, it matches'; # } else { # say "no, it doesn't match"; # } # exit; # # my $string =" "; # my $string ="''"; # # my $pattern = /^\s*$/; # # my $pattern = /^\'*$/; # my $pattern = /^\'$/; # say so $string ~~ $pattern; # if ($string ~~ $pattern) { # say 'yes, it matches'; # } else { # say "no, it doesn't match"; # } # exit; # This removes non-English characters, trailing whitespace, and blank titles ########################## # TASK 4, 5, 6, 7 Below # ########################## ## These are small tasks, where each "<your code here>" ## will be either a regex substitution ## or an if statement and a subsequent action (e.g. skip to next without adding) ########################## # # This loops through each track # for @tracks4_7 -> $title { # ########################## # # LAB 1 TASK 4 # # ########################## # ## Add regex substitutions to (1) leading and trailing apostrophes. # ## and then (2) trim leading and trailing whitespace # ## There will be some trailing apostrophes left after the trailing whitespace is removed # ########################## # # replace leading/trailing apostrophe # say $title; # $_ = $title; # # Uncomment and replace ... with a substition to trim apostrophes # $_ ~~ s:g/^ \'+//; # trim leading apostrophes # $_ ~~ s:g/\'+ $//; # trim trailing apostrophes # say $_; # # Uncomment and replace ... with a substition to trim whitespace # $_ ~~ s:g/^ \s+//; # trim leading whitespace # $_ ~~ s:g/\s+ $//; # trim trailing whitespace # say $_; # # say "\n"; # ########################## End Task 4 # ########################## # # LAB 1 TASK 5 # # ########################## # ## Filter out non-ASCII characters # ## (letters, numbers, apostophe, space allowed) # ########################## # # Use "next;" to skip lines containing non-ASCII characters # ########################## # if ($_ ~~ /<-[a..zA..Z\d\s\']>/) { # say 'yes, skip this'; # say "\n"; # next; # } else { # say "no, keep it"; # } # ########################## # ########################## End Task 5 # ########################## # # LAB 1 TASK 6 # # ########################## # ## Skip title if (1) blank contains only whitespace, # ## or (2) contains only apostrophes # ########################## # # skip if only contains whitespace # ########################## # if ($_ ~~ /^\s*$/) { # next; # } # ########################## # # skip if only contains only an apostrophe # ########################## # # my $pattern = /^\s*$/; # if ($_ ~~ /^\'*$/) { # next; # } # ########################## # ########################## End Task 6 # ########################## # # LAB 1 TASK 7 # # ########################## # ## Set to lowercase # ########################## # # minor edit needed to this line (raku has a handy function) # # @filteredtitles.push: $_.lc; # say $_.lc; # ########################## End Task 7 # say "\n"; # } # # Updates @tracks # # return @filteredtitles; ############################################################################### # my $text = "Hello World, welcome to the world!"; # $text ~~ s:i:g/world/universe/; # say $text; # OUTPUT: "Hello universe, welcome to the universe!" # # exit; # 「hello world」 # say "h!ello worl!d" ~~ rx/ \w+<|wb>\s*<|wb>\w+ /; # 「helloworld」 # say "hello!world" ~~ rx/ \w+<!wb>\s*<!wb>\w+ /; # say "!than the of ! " ~~ /<?after \s><|w>of|the<|w>\s/; # exit; # say "outsanding fatty onery king of hill" ~~ /<?after <|w>>of<?before <|w>>\s?/; # say "Kong of the Hill" ~~ /<?after <|w>>of<?before <|w>>\s?/; # my $string = "To !a Kong of the Hill With the!"; # say $string; # # my $pattern = s:g/<?after <|w>>(a|an|and|by|for|from|in|of|on|or|out|the|to|with)<?before <|w>>//; # # my $pattern = /<?after |w>(of|the|a|an|and|by|for|from|in|on|or|out|to|with)<|w>\s/; # # my $pattern = /<|w>(of|the|a|an|and|by|for|from|in|on|or|out|to|with)<|w>\s/; # # $string ~~ s:i:g/$pattern//; # $string ~~ s:i:g/<|w>(of|the|a|an|and|by|for|from|in|on|or|out|to|with)<|w>\s//; # # $string ~~ s:g/\'+ $//; # say $string; # Output: "Hello World!" # # $string ~~ s:g/^ \s+//; # # $string ~~ s:g/\s+ $//; # # say $string; # exit; ########################## # LAB 1 TASK 8 # ########################## ## Add regex substitutions to remove common stopwords ## Use <|w> (word boundaries) in your regexs ## Also trim the single space following the word ## Use the g (global) directive ## Use the i (case insensitive) directive ########################## for @tracks8 -> $title { ########################## $_ = $title; say $title; # Uncomment and replace ... with a substitution for "a" $_ ~~ s:i:g/<|w>(of|the|a|an|and|by|for|from|in|on|or|out|to|with)<|w>\s//; # Repeat for the other stopwords say $_; say "\n"; ########################## # Add the edited $title to the new array of titles # @filteredtitles.push: $_; } ################################################################################
Editor Settings
Theme
Key bindings
Full width
Lines