How to write a ruby-regular expression that removes characters only in the first and last positions?

I have a log file, most lines are quoted at the first and last characters, for example:

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

What is a ruby ​​regular expression to remove quotes from the head and tail? therefore, the result line looks like this:

 2010-09-09,13:33,"user logoff",0
+3
source share
2 answers
str.gsub /^"|"$/, ''
+8
source

Or without regular expressions:

string[1...-1]
+3
source

Source: https://habr.com/ru/post/1763391/


All Articles