Hi Laurent,

    Thank you!  Another weapon in my tool box!

    Question:  this confused me when I first look at it.  I am use to
    the ":x" command being outside the first "/".  For instance
          s:g/

    What are the rules for what goes inside and what goes outside?

    Also, do y have a link to what the various ":x" commands are
    that I can use?

    I generally prefer to use "contains", "starts-with", and
    "ends-with" when the string is full of trash that regex needs
    to escape.  For example:

    if $Line.contains( '<h1>HWiNFO <span class="modraDownload2">' &
    '</span>
    Installer</h1>' ) {


    Many thanks,
    -T

On 09/10/2018 04:54 AM, Laurent Rosenfeld via perl6-users wrote:
Hi Todd,

you may use:

say "Yes" if "2018 xJul 7" ~~ /:i jul/;

or:

say "Yes" if "2018 xJul 7" ~~ m:i/jul/;

In the second case, the adverb will apply to the whole pattern. In the first case, it will start to apply from the point where the adverb is. In this specific example, those two code samples will be equivalent since the adverb is at the beginning of the pattern. But it would make a difference if the adverb is somewhere else within the pattern. For example, this would fail:

say "Yes" if "2018 xJul 7" ~~ m:i/j :i ul/;

because the ignore case adverb would apply only on the 'ul' characters of the pattern, but not on the 'j'.

More on adverbs in regexes: https://docs.perl6.org/language/regexes#Adverbs

Cheers,
Laurent.


Le lun. 10 sept. 2018 à 00:00, ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> a écrit :

    On 09/08/2018 12:23 PM, Laurent Rosenfeld via perl6-users wrote:
     > Using the fc method is certainly a good way to do case insensitive
     > string comparisons, but you may at this point also use a regex
    with the
     > :i (ignore case) adverb.
     >
     >  > if "2018 xJul 7" ~~ /:i jul/ {say "Yes";}
     > Yes
     >


Thank you!  I will be copying down the section on adverbs
into my documentation.

Question, what the heck is

     my $rx1 = rx:i/a/;

Are they talking over beginner's heads again?

Reply via email to