Programming Windows D Examples are now Online!

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Jun 22 18:36:07 PDT 2011


Ok here's a little challenge for you fokes:

Write a D script that removes extra parens from strings like these:
    ("Acoustic Bass Drum"), ("Bass Drum 1"),
    ("Side Stick"), ("Acoustic Snare"),
    ("Hand Clap"), ("Electric Snare"),
    ("Low Floor Tom"), ("Closed High Hat"),
    ("High Floor Tom"), ("Pedal High Hat"),

and replaces it with:
    "Acoustic Bass Drum", "Bass Drum 1",
    "Side Stick", "Acoustic Snare",
    "Hand Clap", "Electric Snare",
    "Low Floor Tom", "Closed High Hat",
    "High Floor Tom", "Pedal High Hat",

I can't figure std.regex out. Every time I try to use the hit()
property of a RegexMatch object I get back some weird internal error:

core.exception.AssertError at D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\regex.d(1861):
4294967295 .. 4294967295 vs. 2

The parens are leftover from code like this:
     TEXT ("Acoustic Bass Drum"), TEXT ("Bass Drum 1"),
     TEXT ("Side Stick"),         TEXT ("Acoustic Snare"),
     TEXT ("Hand Clap"),          TEXT ("Electric Snare"),
     TEXT ("Low Floor Tom"),      TEXT ("Closed High Hat"),
     TEXT ("High Floor Tom"),     TEXT ("Pedal High Hat"),

TEXT was just a macro that would probably add a function call if the C
code was compiled with unicode support. I did a global search and
replace of TEXT but that left me with a minefield of parens. :)

Maybe this will help:
http://www.txt2re.com/index.php3?s=%28%22Acoustic+Bass+Drum%22%29&submit=Show+Matches


More information about the Digitalmars-d-announce mailing list