From: Gavin Kistner Date: 2005-09-05T09:26:48+09:00 Subject: Re: Making my Regex less greedy? On Sep 4, 2005, at 5:51 PM, luke wrote: > The logic I'd like the above regex to operate with is: "Starting 100 > characters into the message, chop the message at the next paragraph > break". The question mark makes quantifiers non-greedy. .+ versus .+? .* versus .*? .{a,b} versus .{a,b}? For example: txt = <["Twas brillig", "and the slithy toves\ndid gyre and gimble\nin the wabe\n"] p truncate_after( txt, 20 ) #=>["Twas brillig\nand the slithy toves", "did gyre and gimble\nin the wabe\n"] p truncate_after( txt, 40 ) #=>["Twas brillig\nand the slithy toves\ndid gyre and gimble", "in the wabe\n"]