From: Kent Dahl Date: 2003-05-13T00:02:34+09:00 Subject: Re: Regexp: why does (re)* return only last repetition? Austin Ziegler wrote: > > On Mon, 12 May 2003 17:39:19 +0900, Robert Klemme wrote: > > Clifford Heath: > >> Robert Klemme wrote: > >>> Clifford Heath: > >>>> re = Regexp.new('[a-z\\]') > >>> Why not simply do > >>> re = /[a-z\\]/ > >> Because it was part of a larger extended re. > > But you can still use re = /.../ instead of re = Regexp.new '...' > > Again, if and only if one is specifying the regular expression > statically. Am I missing something or just misunderstanding what you mean by specifying it statically? def check( name, string ) puts /Mr\. (#{name.capitalize})/.match(string)[1] end check "nelson", "Hello Mr. Nelson, how are you?" #=> Nelson -- (\[ Kent Dahl ]/)_ _~_ __[ http://www.stud.ntnu.no/~kentda/ ]___/~ ))\_student_/(( \__d L b__/ NTNU - graduate engineering - 5. year ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)