Re: need <-[x]> help

2018-05-03 Thread Fernando Santagata
Hi Todd,

I tried to match a single string to begin with:

my $x = '"7" ab"';
$x ~~ s:g/ (.) \"  /inches($0)/;
say $x;

# "inches(7) ab"

On Thu, May 3, 2018 at 12:11 PM Todd Chester  wrote:

> Hi All,
>
> What I am trying to do is to replace a quote `"`
> with `inches`, but NOT when the quote is followed
> by a comma `,`.
>
> In other words, ignore `",`
>
> I am not having too good a time with it.  What am I
> doing wrong?
>
> $ perl6 -e 'my $x=qw["44","7" ab","","999"]; say
> "$x";$x~~s:g/\"(.)<-[,]>/ inches($0)/; say "$x";'
>
> "44","7" ab","","999"
> inches(4)inches(,)7inches( )binches(,)inches(,)999"
>
> desired output:
> "44","7 inches ab","","999"
>
> Many thanks,
> -T
>
> next step, ignoring the quote at the end of the line.
>


-- 
Fernando Santagata


Re: need <-[x]> help

2018-05-03 Thread jerry gay
you want a negative lookahead assertion, which are described (with an
example) at https://docs.perl6.org/language/regexes#Lookahead_Assertions

On Thu, May 3, 2018 at 3:10 AM, Todd Chester  wrote:

> Hi All,
>
> What I am trying to do is to replace a quote `"`
> with `inches`, but NOT when the quote is followed
> by a comma `,`.
>
> In other words, ignore `",`
>
> I am not having too good a time with it.  What am I
> doing wrong?
>
> $ perl6 -e 'my $x=qw["44","7" ab","","999"]; say "$x";$x~~s:g/\"(.)<-[,]>/
> inches($0)/; say "$x";'
>
> "44","7" ab","","999"
> inches(4)inches(,)7inches( )binches(,)inches(,)999"
>
> desired output:
> "44","7 inches ab","","999"
>
> Many thanks,
> -T
>
> next step, ignoring the quote at the end of the line.
>


need <-[x]> help

2018-05-03 Thread Todd Chester

Hi All,

What I am trying to do is to replace a quote `"`
with `inches`, but NOT when the quote is followed
by a comma `,`.

In other words, ignore `",`

I am not having too good a time with it.  What am I
doing wrong?

$ perl6 -e 'my $x=qw["44","7" ab","","999"]; say 
"$x";$x~~s:g/\"(.)<-[,]>/ inches($0)/; say "$x";'


"44","7" ab","","999"
inches(4)inches(,)7inches( )binches(,)inches(,)999"

desired output:
"44","7 inches ab","","999"

Many thanks,
-T

next step, ignoring the quote at the end of the line.