And my response to his response that also was unintentionally off-list.

(Todd, if you don't mind resending your last private response—since your
other response was quoted below—in reply to this, please do.)

On Mon, Sep 10, 2018 at 22:00 ToddAndMargo <toddandma...@zoho.com> wrote:
> So you get to iteratively pick what the regex will be.
> I can see where this would be very powerful. Thank you!
>
> Also, really a bad idea to use in documentation
> as it "presumes" that the reader is very advanced in
> his knowledge of regex's. In which case he would
> not need to read the documentation anyway.

Pardon? I don't follow. "Really a bad idea to use" what?

Personally, I get rather annoyed when I have to sift through Yet Another
Introduction to Regexes just in order to find out how to use regexes in a
particular language or library. The documentation for a regex library
shouldn't explain regexes, if that's what you're saying. Most programmers
will be coming to any new language already knowing regexes of some sort.

I don't see what's "very advanced in... knowledge of regex[es]". Those
examples don't even use quantifiers; they're just fixed text matches with
case-insensitivity. If you find that "advanced", you should do one of the
many excellent regex tutorials available in whatever languages or
programmable editors you already know—trying to learn regexes and a new
language simultaneously will be a bit overwhelming, as regexes are a
language and practice unto themselves.

Perl 6's regex syntax is rather different from other languages' (a bit
amusingly, since in the meantime other modern languages have mostly
coalesced around adopting something close to Perl 5's), but you'll be much
better-equipped to understand them in Perl 6 if you understand them in
general first.


On Tue, Sep 11, 2018 at 18:49 Trey Harris <t...@lopsa.org> wrote:

> Oops— I sent the following yesterday and it somehow didn't go to the list:
>
> On Mon, Sep 10, 2018 at 19:02 ToddAndMargo <toddandma...@zoho.com> wrote:
>
>> Question, what the heck is
>>
>>       my $rx1 = rx:i/a/;
>>
>> Are they talking over beginner's heads again?
>>
>
> In the sense of "beginners to Perl", perhaps, since "rx" is familiar to
> Perl 5 programmers.
>
> Though if you search docs.perl6.org for "rx" you'll see a choice in the
> pop-down, "rx (quote)", which leads to:
>
> https://docs.perl6.org/language/regexes#index-entry-quote_%2F_%2F-quote_rx-quote_m-Lexical_conventions
>  and
> that says:
>
> ```
>
> Perl 6 has special syntax for writing regexes:
>
>     m/abc/;         # a regex that is immediately matched against $_
>
>     rx/abc/;        # a Regex object; allow adverbs to be used before regex
>
>     /abc/;          # a Regex object; shorthand version of 'rx/ /' operator
> ```
>
> That entire section of the documentation is worth reading as it describes
> everything discussed in this thread.
>
> But in case it isn't clear, it just means that if you do
>
>     my $result = "Juli 2018" ~~ m:i/jul/;
>
> then you'll get a match containing "Jul" as a result.
>
> It so happens in this case, when using ~~ against a literal like above,
> m// and rx// are pretty much interchangeable.
>
> But you could also do:
>
>     my $pattern = rx:i/jul/;
>     my $result = "Juli 2018" ~~ $pattern;
>
> and get the same result.
>
> If you tried to do
>
>    my $pattern = m:i/jul/;
>
> You'll get an exception unless the $_ topic variable happens to contain a
> thing that can be regex-matched (like a string). The `m` explicitly causes
> the match to happen immediately.
>

Reply via email to