use strict;
my $str = 'Column,Row,Value,Column Title,Question,Answer
A,1,100,Comics,"This series following a team of mutants, was actually cancelled during it\'s first run and did not reach its popular status until a revival severla years later.",X-Men
A,2,200,Comics,This demonic hero has a big gun and an even bigger right fist.,Hellboy
A,3,300,Comics,This mostly self-published series follows three osteo-minded cousins through a series of misadventures.,Who is...
A,4,400,Comics,"Superman may be considered the first, but this magical superhero also debuted in Action Comics #1, 7 pages after Superman.",Zatara
A,5,500,Comics,"Sharing the alias of a few villainous iterations in the main comics, this character from the ""What If?"" line of comics is a spider bitten by a radioactive human.",Webster Weaver / Man-Spider
B,1,100,Disney,"One of these per day will keep the doctor away, but a poisoned one requires a visit from nobility.",An Apple
B,2,200,Disney,"This character, one of seven of his kind, is the only one who\'s name is not an adjective.",Doc
B,3,300,Disney,This kitchen essential is the weapon of choice for Rapunzel.,A cast iron frying pan
B,4,400,Disney,Billy Joel lends his voice to this canine character.,Dodger
B,5,500,Disney,This is the last animated feature to be produced by Walt Disney until his death in 1966.,The Jungle Book
C,1,100,MTG,"A player of the game is called this, eventually added as a card type.",A Planeswalker
C,2,200,MTG,Much of early Magic is set on this plane.,Dominaria
C,3,300,MTG,This space between planes is also the original home of the Eldrazi.,The Blind Eternities
C,4,400,MTG,"Often mistakenly used when referring to double face cards, this mechanic originated in Kamigawa block",Flip Cards
C,5,500,MTG,This base set is the first set designated with a numbered release.,Fourth Edition
D,1,100,Pokemon,"""Ay cutie, are you an electric rodent or can I get a...""",Pikachu
D,2,200,Pokemon,"In the card game, there are this many basic energy types",Nine
D,3,300,Pokemon,This fighting type pokemon\'s english name is partially inspired from a famous action comedy movie star.,Hitmonchan
D,4,400,Pokemon,"In the original anime, albeit being a generation 2 pokemon officially, this is the first legendary Pokemon Ash Ketchum sees.",Ho-oh
D,5,500,Pokemon,"As of generation 9, this is the most common type of Pokemon",Water
E,1,100,Board Games,This generic wooden piece is usually used to represent a person.,A meeple
E,2,200,Board Games,This board game changed a rule to allow proper nouns and it has been downhill ever since.,Scrabble
E,3,300,Board Games,This board game takes its name and theme from a famous road in Japan.,Tokaido
E,4,400,Board Games,The commonly used standard playing card deck has origins in this Europeon country. ,France
E,5,500,Board Games,"This is what a super nerd calls a 20-sided die, also known as it\'s geometric name.",icosahedron
F,1,100,"Words that rhyme with ""piss""",A cat or a snake will perform this when upset.,Hiss
F,2,200,"Words that rhyme with ""piss""",You may give one of these to someone you love.,Kiss
F,3,300,"Words that rhyme with ""piss""","When class is over, the teacher will perform this action.",Dismiss
F,4,400,"Words that rhyme with ""piss""","If you stare into this for too long, it will stare back at you.",Abyss
F,5,500,"Words that rhyme with ""piss""",When you remember fondly.,Reminisce';
my $regex = qr/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/p;
if ( $str =~ /$regex/ ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html