Hi Peter,

On 30.05.2014 22:39, Peter Schwenn wrote:
> Dear Moritz,
> 
> $txt ~~ s:g/ <!before System> \. Guid  /.Moniker/;
> 
> transforms (in $txt):    System.Guid -> System.Moniker
> 
> i.e. the match succeeds.  So obviously I'm not understanding negative
> look-ahead correctly.  Where's there a good description of negative look
> ahead. 

The look-ahead looks *ahead*, that is, it matches because where the
regex matches '.Guid', the next token isn't 'System'.

So either write the look-ahead like this:

$txt ~~ s:g/ <!before System> « \w+ \. <( Guid /Moniker/;

(The <( limits where the substitution starts).

or use a look-behind:

s:g/ <!after 'System'> \. Guid /.Moniker/;


For a general introduction into look-araound assertions (and many other
regex topics) I can recommend "Mastering Regular Expressions" by Jeffrey
Friedl. It mostly uses Perl 5 regex syntax, but the concepts translate
well to Perl 6.

Cheers,
Moritz

Reply via email to