From: Assaph Mehr Date: 2005-01-18T06:51:05+09:00 Subject: Re: My regexp stupidity needs assistance before loose all my hair! > Thanks. I _see_ now why mine wasn't working, though I don't > _understand_ why it wasn't working. I was using the / /x extension, > because I generally like to space the parts my regexps out to > read easier, but for some reason that causes the above to > match [b] instead. Oh well, I just won't do that. It has todo with the pattern matching being greedy, not the /x flag. your pattern will match a '[' then as many characters as possible - including ']' - until a final closing ']'. There are two solutions: 1. As shown, match any non ']'. 2. Make the match non greedy: %r{ \[(.+?)\] }x HTH, Assaph ps. If you want all occurences in the string, use string#scan instead of String#match.