> I'm having some trouble finding an elegant way of removing a part of a
> string based on an pattern.

str = "BeginOfString"
str[/Begin/]    => "Begin"
str[/Of/]       => "Of"

if you want to restrict it to the beginning, do

str[/^Begin/]   => "Begin"
str[/^Of/]      => nil

and then for replacing it, or removing it

str[/^Begin/] = ""   => ""
str                  => "OfString"
str[/Of/] = "a"      => "a"
str                  => "aString"

For lots more of information on patterns, read the regexp chapter of the
pickaxe.

hth,
Kero.

+--- Kero ------------------------- kero@chello@nl ---+
|  all the meaningless and empty words I spoke        |
|                       Promises -- The Cranberries   |
+--- M38c --- http://members.chello.nl/k.vangelder ---+