I understand your issues- try the regexp in my recent post, without
splitting & re-joining. Also, the margin removal aka "remove the final
slash an what's after it" can be simpler.

my $LabelStr='"00046436405","HALT 3/4" ORIG LNG #35-1333-RD/.55 +
SHP","","     3/4","      don\'t give an"","      0.00","      0.00","
0.00","","","      0.00","35-1002-RD","WEAV","","","BRIDL","",""';

say $LabelStr, "\n";

$LabelStr ~~ s:g/(<!before ^> && <!after \, >) \" <!before \, | \s*$ >/
inch/;
$LabelStr ~~ s| \/ <-["/]>+ \" | \" |;
say $LabelStr;


The root problem is that CSV is an ad-hoc format and you've received a
particularly bad flavor...

-y

On Fri, May 4, 2018 at 6:10 AM, Todd Chester <toddandma...@zoho.com> wrote:

>
>
> On 05/03/2018 10:52 PM, yary wrote:
>
>> What you really want is to change a quote to "inch" if the quote is
>> not at the start of the line, not preceeded by a comma, not followed
>> by a comma, and not at the end of a line.
>>
>> $LabelStr ~~ s:global|"3/4\""|3/4 inch|;
>>>
>>
>> But that will only fix inch when it is after 3/4
>> how about
>>
>
> On purpose.  I have to put one in for 1/4", 1/2",
> 1", 2" too.  Since this is the 32 bit version of that
> OS, whose name I shall not mention (I hear it is slow,
> buggy, and really expensive), I am relegated to using a
> 32 bit Perl 6 dating back to 2016, which is
> buggy enough to match the buggy OS it is running on.
> A match made in, well this is a family friendly forum.
>
> This is a long string filled with multiple
> lines delimited by \n's full of comma delimited
> fields `"vvv","gg","ee"` and the only way
> I can insure I only get the `"` that some
> one filled in for inches, and not the `","`
> delimiter, is to include what came before it.
> Otherwise several of the `"` also get clobbered,
> ruining the `","` format.
>
> Mind you, I can run these regex's on my current version
> of Perl 6 on Fedora and they run perfectly.
>
> So I am trying to work around the bugs in this
> old version of Perl 6.
>
>
>> $_='"6" hand","7" foot","8 10" '
>>>
>> "6" hand","7" foot","8 10"
>>
>>> s:g/(<!before ^> && <!after \, >) \" <!before \, | \s*$ >/ inch/; $_
>>>
>> "6 inch hand","7 inch foot","8 10"
>>
>> I am a bit perplexed at the asymmetry - thought it would work with
>> s:g/<!after ^\s* | \, > \" <!before \, | \s*$ >/ inch/ - I put a
>> question in perl6-language about that.
>>
>> -y
>>
>>
> The current bug I have to work around is s:global
> only catching the last instance of the string.
>
> I will have to `split \n` and operate on the string
> one line at a time, then put the string back together.
>
> Such is life in the fast lane.  I could have used Perl 5,
> but one has to draw a line in the sand somewhere ...
>
> Happy \/\\\\/\//\/\/ coding!
>
> -T
>

Reply via email to