R
Rodney
I have a situation where I want to send portions of a line of text to a
subroutine for processing. The text line could look like this:
blah blah <!--Start-- blah blah blah--End--> blah blah blah <!--Start-- blah
blah--End--> blah blah blah.
I only want to send the text that is NOT within the <!--Start-- and --End-->
tags. So example above would have 3 pieces of text the need to run through
the subroutine.
After they go through the subroutine, the line of text needs to be regrouped
in the same order it was before it was processed and the "Tags" have to be
in tact.
I've tried "splitting" the line and working with the array elements.... but
this process seems to take a VERY long time.
see example below:
#==================================================start
sub AddKeyWordsAndNumericConst {
my ($TextBlockToConvert) = @_;
my $TextBlockToConvert2 = "";
my $TextBlockToConvert3 = "";
### beginning tag looks like this: <!-- Quoted Text Start QTS-->
@CodeBreakApart = split(/<!-- Quoted Text Start /,
$TextBlockToConvert) ;
for($ArrayTicker3=0; $ArrayTicker3 < @CodeBreakApart; $ArrayTicker3++)
{
$CodeBreakTest = $CodeBreakApart[$ArrayTicker3];
if (not($CodeBreakTest =~ m/QTS-->/g)) {
$CodeBreakTest = &OpalNumberConstants($CodeBreakTest);
$CodeBreakTest = &OpalKeywords($CodeBreakTest);
$CodeBreakApart[$ArrayTicker3] = $CodeBreakTest;
$CodeBreakTest = "";
$TextBlockToConvert2 =
$TextBlockToConvert2.$CodeBreakApart[$ArrayTicker3];
}
else {
$CodeBreakTest = "<!-- Quoted Text Start ".$CodeBreakTest;
$CodeBreakApart[$ArrayTicker3] = $CodeBreakTest;
$CodeBreakTest = "";
$TextBlockToConvert2 =
$TextBlockToConvert2.$CodeBreakApart[$ArrayTicker3];
}
}
### end tag looks like this: <!-- Quoted Text End QTE-->
@CodeBreakApart2 = split(/QTE-->/, $TextBlockToConvert2) ;
for($ArrayTicker4=0; $ArrayTicker4 < @CodeBreakApart2; $ArrayTicker4++)
{
$CodeBreakTest2 = $CodeBreakApart2[$ArrayTicker4];
if (not($CodeBreakTest2 =~ m/<!-- Quoted Text End /g)) {
$CodeBreakTest2 = &OpalNumberConstants($CodeBreakTest2);
$CodeBreakTest2 = &OpalKeywords($CodeBreakTest2);
$CodeBreakApart2[$ArrayTicker4] = $CodeBreakTest2;
$CodeBreakTest2 = "";
$TextBlockToConvert3 =
$TextBlockToConvert2.$CodeBreakApart2[$ArrayTicker4];
}
else {
$CodeBreakTest2 = $CodeBreakTest2."QTE-->";
$CodeBreakApart2[$ArrayTicker4] = $CodeBreakTest2;
$CodeBreakTest2 = "";
$TextBlockToConvert3 =
$TextBlockToConvert2.$CodeBreakApart2[$ArrayTicker4];
}
}
return $TextBlockToConvert3;
}
#===============================================end
My question is:
1) Is there a RegEx statement that would do this.... only faster?
2. If not, is there a way to make the above process faster?
Thanks
subroutine for processing. The text line could look like this:
blah blah <!--Start-- blah blah blah--End--> blah blah blah <!--Start-- blah
blah--End--> blah blah blah.
I only want to send the text that is NOT within the <!--Start-- and --End-->
tags. So example above would have 3 pieces of text the need to run through
the subroutine.
After they go through the subroutine, the line of text needs to be regrouped
in the same order it was before it was processed and the "Tags" have to be
in tact.
I've tried "splitting" the line and working with the array elements.... but
this process seems to take a VERY long time.
see example below:
#==================================================start
sub AddKeyWordsAndNumericConst {
my ($TextBlockToConvert) = @_;
my $TextBlockToConvert2 = "";
my $TextBlockToConvert3 = "";
### beginning tag looks like this: <!-- Quoted Text Start QTS-->
@CodeBreakApart = split(/<!-- Quoted Text Start /,
$TextBlockToConvert) ;
for($ArrayTicker3=0; $ArrayTicker3 < @CodeBreakApart; $ArrayTicker3++)
{
$CodeBreakTest = $CodeBreakApart[$ArrayTicker3];
if (not($CodeBreakTest =~ m/QTS-->/g)) {
$CodeBreakTest = &OpalNumberConstants($CodeBreakTest);
$CodeBreakTest = &OpalKeywords($CodeBreakTest);
$CodeBreakApart[$ArrayTicker3] = $CodeBreakTest;
$CodeBreakTest = "";
$TextBlockToConvert2 =
$TextBlockToConvert2.$CodeBreakApart[$ArrayTicker3];
}
else {
$CodeBreakTest = "<!-- Quoted Text Start ".$CodeBreakTest;
$CodeBreakApart[$ArrayTicker3] = $CodeBreakTest;
$CodeBreakTest = "";
$TextBlockToConvert2 =
$TextBlockToConvert2.$CodeBreakApart[$ArrayTicker3];
}
}
### end tag looks like this: <!-- Quoted Text End QTE-->
@CodeBreakApart2 = split(/QTE-->/, $TextBlockToConvert2) ;
for($ArrayTicker4=0; $ArrayTicker4 < @CodeBreakApart2; $ArrayTicker4++)
{
$CodeBreakTest2 = $CodeBreakApart2[$ArrayTicker4];
if (not($CodeBreakTest2 =~ m/<!-- Quoted Text End /g)) {
$CodeBreakTest2 = &OpalNumberConstants($CodeBreakTest2);
$CodeBreakTest2 = &OpalKeywords($CodeBreakTest2);
$CodeBreakApart2[$ArrayTicker4] = $CodeBreakTest2;
$CodeBreakTest2 = "";
$TextBlockToConvert3 =
$TextBlockToConvert2.$CodeBreakApart2[$ArrayTicker4];
}
else {
$CodeBreakTest2 = $CodeBreakTest2."QTE-->";
$CodeBreakApart2[$ArrayTicker4] = $CodeBreakTest2;
$CodeBreakTest2 = "";
$TextBlockToConvert3 =
$TextBlockToConvert2.$CodeBreakApart2[$ArrayTicker4];
}
}
return $TextBlockToConvert3;
}
#===============================================end
My question is:
1) Is there a RegEx statement that would do this.... only faster?
2. If not, is there a way to make the above process faster?
Thanks