Hi --

On Thu, 18 Sep 2008, Fritzek wrote:

> Hi folks
>
> short question how to use regexp the right way
> given is a="a[b]c"
> I nedd b="a c"
>
> tried to split using (/(\[|\])/) to get  ["a", "[", "b", "]", "c"]
>
> b=a.strip.split(/(\[|\])/)
>
> and then joined the bits together. this just works in a simple case
> like "a[b]c", but "[b]" could occur multiple times.
>
> I need something like search for any "[b]" and substitute with a
> blank.

b = a.delete("[b]")


David

-- 
Rails training from David A. Black and Ruby Power and Light:
   Intro to Ruby on Rails  January 12-15   Fort Lauderdale, FL
   Advancing with Rails    January 19-22   Fort Lauderdale, FL *
   * Co-taught with Patrick Ewing!
See http://www.rubypal.com for details and updates!