From: Mark Sparshatt Date: 2004-07-04T21:39:27+09:00 Subject: Re: Regular expression question George Moschovitis wrote: >Hello everyone! > >I have a question regarding regular expressions. Let me explain >with an example. I have the string: > >"{b}Text{/b} kokoko {b}Lalal{/b}" > >and i want to convert it to this string > >"Text kokoko Lalal" > >if I use the following gsub: > >str.gsub!(/\{b\}(.*)\{\/b\}/, '\1') > > try this str.gsub!(/\{b\}(.*?)\{\/b\}/, '\1') at the moment the .* is being too greedy when it's matching, causing it to match Text{/b} kokoko {b}Lalal Using .*? switches off the greedy matching so it only matches up to the first {/b} HTH -- Mark Sparshatt