I have a *TEX file contains:
__DATA__
"\left({H^1}, \int {H^2}\right)"
"\left({H^1},\bigoplus{H^2}\right)"
"\left({H^1},{H^2}\right)"
"\left({H^1}, \bigvee {H^2}\right)"
The above *TEX contents I have to check the list of array elements which I have listed below: If any one the elements is matched then retain the line as it is: If no one of the elements matched then I need to replace \left( into ( and \right) into ).
My Arrays:
int frac prod sum oint bigvee bigcup bigcap bigoplus bigotimes
Expected Output:
"\left({H^1}, \int {H^2}\right)"
"\left({H^1},\bigoplus{H^2}\right)"
"({H^1},{H^2})"
"\left({H^1}, \bigvee {H^2}\right)"
What I have tried:
my @mathenv = qw(int frac prod sum oint bigvee bigcup bigcap bigoplus bigotimes);
while(<DATA>) { $mathchk .= $_; }
$boolChk = 'False';
$mathchk=~s#\\left\(((?:(?!\\(?:left|right)).)*)\\right\)# my $fulcnt=$&; my $Content=$1;
foreach my $singlemath(@mathenv)
{
\#print "S: -$singlemath-\n";
if($fulcnt=~m/\\$singlemath/gi)
{ $boolChk = 'True'; }
}
print ": $boolChk \t$fulcnt\n"; system 'pause';
if($boolChk eq 'True') { }
if($boolChk eq 'False') { $fulcnt = "\($Content\)"; }
($fulcnt);
#esg;
#print $mathchk;
__DATA__
"\left({H^1}, \int {H^2}\right)"
"\left({H^1},\bigoplus{H^2}\right)"
"\left({H^1},{H^2}\right)"
"\left({H^1}, \bigvee {H^2}\right)"
I couldn't able to get the correct output hence if someone guide me where I have to modify the above code. Thanks in advance.