develooper Front page | perl.perl6.users | Postings from September 2018

Need help with a variable inside a regex

Thread Next
From:
ToddAndMargo
Date:
September 15, 2018 07:42
Subject:
Need help with a variable inside a regex
Message ID:
532b683c-4c7e-202a-4562-d7f23e2f6abf@zoho.com
Hi All,

I am truing to use a variable inside a regex.

This work (without the variable):
    $ p6 'my $x="6937-2.2.19882.exe"; if $x ~~ m/ .*? <<:\N**4>>  "-" 
(.*?) ".exe" / {say "yes";}'
    yes

I want to turn `<<:\N**4>>` into a variable:


    $ p6 'my $x="6937-2.2.19882.exe"; my $i="<<:\\N**4>>"; if $x ~~ m/ 
.*? $i  "-" (.*?) ".exe" / {say "yes";}else{say "No"}; say "$i";'

    No
    <<:\N**4>>

The double \\ is to get it past bash


What am I doing wrong?

Many thanks,
-T

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About