Removing quotes from a string

So, I thought it would be just a problem, but I am getting the wrong results. I am basically trying to remove quotes around a string. For example, I have the line “01:00” and I want 01:00, the code below shows how I thought I could do this:

$expected_start_time = $conditions =~ m/(\"[^\"])/;

Each time this is executed, it returns 1, so I assume that it simply returns true, and does not extract a string from quotes. This happens regardless of what is in the quotes “02:00”, “02:20”, “08:00”, etc.

+5
source share
4 answers

, , parens LHS, , . :

 ($expected_start_time) = $condition =~ /"([^"]*)"/;
+13

, , - ,

$expected_start_time = substr $conditions, 1, -1;

.

+9

:

$expected_start_time = $conditions;
$expected_start_time =~ s/"//g;

, :

m/(\"[^\"])/

. , :

m/"([^"]*)"/;

Perl ( ), TMTOWTDI - , .

+4

regex true, . $1. . perlre.

+1

All Articles