开发者

How to write a ruby regex that removes characters only at first and last positions?

I have a log file, most lines are quoted at first and last character, like:

 "2010-09-09,13:33,"user logoff",0"

What's the ruby regex to remove the head and tail quotation marks? so the result string looks like:

开发者_JAVA技巧
 2010-09-09,13:33,"user logoff",0


str.gsub /^"|"$/, ''


Or without regular expressions:

string[1...-1]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜