jbcedge
jbcedge

Reputation: 19515

reading string inside quotes in perl

This is the string:

[quote="test post1"]this is a test post[/quote]

I want to retrieve only test post1 value

This is what I am doing...

[tmp test][item-param body] [/tmp]
$str1 = $Scratch->{test};
$str1 =~ m/"(.?)"/;

But it's not giving is the expected value: test post1

Any help will be appreciated.

Upvotes: 1

Views: 165

Answers (1)

user993553
user993553

Reputation: 1077

#!/usr/bin/perl;

my $str = '[quote="test post1"]this is a test post[/quote]';

if($str=~m/\"(.+)\"/) {
print $1;
}

Upvotes: 1

Related Questions