From: camenix Date: 2006-11-05T21:05:13+09:00 Subject: How to match last word? Hi,all I has a script to match 'Transfer dbf to SQLServer', the last comand successfully ended.But I found no way to match last command.Whoever can help me? main.rb string=' Program begin at 2006-11-05T15:01:13+0800 Change image name to lower begin at 2006-11-05T15:01:13+0800 Change image name to lower end at 2006-11-05T15:01:14+0800 Transfer dbf to SQLServer begin at 2006-11-05T15:01:14+0800 Transfer dbf to SQLServer end at 2006-11-05T15:01:15+0800 Modify Tables begin at 2006-11-05T15:01:15+0800 ' re=/\n{0,1}(.+?)\s+(end\s+at)(.+?)\n/i re.match(string) puts $1,$2,$3,$4 The string is came from a file,so the "\n" maybe ommited,but /\n{0,1}(.+?)\s+(end\s+at)(.+?)(\n|\Z)/i didn't work. This form of regular expresion always match 'Change image name to lower'.($2)