From: T K Date: 2008-03-17T21:45:11+09:00 Subject: Replacing based on regular ecpressions Hi, I'm writing a ruby script that does a batch search-and-replace command. In each line of the file that is opened, I would like to delete part of the entire part matched by a regrex. For example, line.gsub(/(Tennis\/Soccer\/.+?).+?){ puts $& # entire match puts $1 # the first match } I can successfuly identify the parts I need in the regres, now I want to only keep the first match. Something like "$&" - "$1". I tried different methods such as String#delete, but they didn't work for me. -T