Re: How do I do literal quotes in a regex?

2019-12-10 Thread ToddAndMargo via perl6-users

On 2019-12-09 00:46, Fernando Santagata wrote:
On Mon, Dec 9, 2019 at 9:38 AM Fernando Santagata 
mailto:nando.santag...@gmail.com>> wrote:


It can be used this way:

$ raku -e'say „Hello!“'
Hello!
But it must be used with that closing quote '“' (U+201C); it cannot
be used paired with itself:


There's another quotation mark that can be used with '„', it's '”' 
(U+201D). I know, it's difficult to see the difference :-)


$ raku -e'say „Hello!„'
===SORRY!=== Error while compiling -e
Unable to parse expression in low curly double quotes; couldn't find
final <[”“]> (corresponding starter was at line 1)
at -e:1
--> say „Hello!„⏏
     expecting any of:
         argument list
         low curly double quotes
         term

Your take: for maintainability, is it better to use
these unicodes or to just stick with escaping things?


I don't think there's a maintainability issue with Unicode
operators, because everyone has a plain ASCII counterpart; besides,
their meaning is quite apparent or in some cases even better than
their ASCII counterpart: consider the set union operator ∪ vs (|),
the first being the universally accepted mathematical symbol, while
I find the second difficult to interpret and remember.

-- 
Fernando Santagata




--
Fernando Santagata



Thank you!

I already have a keeper going with useful unicodes.

-T


Re: How do I do literal quotes in a regex?

2019-12-09 Thread Trey Harris
On Mon, Dec 9, 2019 at 03:54 Fernando Santagata 
wrote:

> On Mon, Dec 9, 2019 at 9:38 AM Fernando Santagata <
> nando.santag...@gmail.com> wrote:
>
>> It can be used this way:
>>
>> $ raku -e'say „Hello!“'
>> Hello!
>> But it must be used with that closing quote '“' (U+201C); it cannot be
>> used paired with itself:
>>
>
> There's another quotation mark that can be used with '„', it's '”'
> (U+201D). I know, it's difficult to see the difference :-)
>

It’s easier to see in serif typefaces. Traditionally, pairing „Hello!“
(with U+201C) is how German used it and „Hello!” (with U+201D) is how Dutch
used it. But those conventions aren’t as rigidly set as in some other
languages. In any case, it makes sense to allow either left- or
right-closing double quotation mark in closing.


Re: How do I do literal quotes in a regex?

2019-12-09 Thread Fernando Santagata
On Mon, Dec 9, 2019 at 9:38 AM Fernando Santagata 
wrote:

> It can be used this way:
>
> $ raku -e'say „Hello!“'
> Hello!
> But it must be used with that closing quote '“' (U+201C); it cannot be
> used paired with itself:
>

There's another quotation mark that can be used with '„', it's '”'
(U+201D). I know, it's difficult to see the difference :-)

$ raku -e'say „Hello!„'
> ===SORRY!=== Error while compiling -e
> Unable to parse expression in low curly double quotes; couldn't find final
> <[”“]> (corresponding starter was at line 1)
> at -e:1
> --> say „Hello!„⏏
> expecting any of:
> argument list
> low curly double quotes
> term
>
> Your take: for maintainability, is it better to use
>> these unicodes or to just stick with escaping things?
>>
>
> I don't think there's a maintainability issue with Unicode operators,
> because everyone has a plain ASCII counterpart; besides, their meaning is
> quite apparent or in some cases even better than their ASCII counterpart:
> consider the set union operator ∪ vs (|), the first being the universally
> accepted mathematical symbol, while I find the second difficult to
> interpret and remember.
>
> --
> Fernando Santagata
>


-- 
Fernando Santagata


Re: How do I do literal quotes in a regex?

2019-12-09 Thread Fernando Santagata
On Mon, Dec 9, 2019 at 1:27 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> What is the unicode for the subscript double quote „ ?
>

That's U+201E

and can it be used together with the regular
> quote the same as 「」 ?
>

It can be used this way:

$ raku -e'say „Hello!“'
Hello!
But it must be used with that closing quote '“' (U+201C); it cannot be used
paired with itself:
$ raku -e'say „Hello!„'
===SORRY!=== Error while compiling -e
Unable to parse expression in low curly double quotes; couldn't find final
<[”“]> (corresponding starter was at line 1)
at -e:1
--> say „Hello!„⏏
expecting any of:
argument list
low curly double quotes
term

Your take: for maintainability, is it better to use
> these unicodes or to just stick with escaping things?
>

I don't think there's a maintainability issue with Unicode operators,
because everyone has a plain ASCII counterpart; besides, their meaning is
quite apparent or in some cases even better than their ASCII counterpart:
consider the set union operator ∪ vs (|), the first being the universally
accepted mathematical symbol, while I find the second difficult to
interpret and remember.

-- 
Fernando Santagata


Re: How do I do literal quotes in a regex?

2019-12-08 Thread ToddAndMargo via perl6-users

On 2019-12-08 19:34, Brad Gilbert wrote:

I like to use them, but I am not you.


Hi Brad,

I am going to create a keeper and give it a shot!

It is not like I don't have four or five of them
open when I am programming

:-)

-T


Re: How do I do literal quotes in a regex?

2019-12-08 Thread Brad Gilbert
I like to use them, but I am not you.

On Sun, Dec 8, 2019 at 8:19 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 2019-12-08 18:04, Brad Gilbert wrote:
> > I do not quite understand the question.
> >
> > I told you how to directly enter unicode by remembering the codepoint.
> >
> > It's still the same characters.
> >
> > I would definitely recommend setting up, and getting used to Compose
> keys.
> >
> > I use them all the time for things like « » ‘ ’ “ ” ¹²³⁴⁵⁶⁷⁸⁹⁰¯⁺≠
>
> I was not asking if they were any good or not.
>
> I was asking if you thought someone like me, who
> would have to look the them up every time, should
> just stick with the what is on the keyboard.
>
> At times I have just had a list of them I could just
> copy and paste.
>
> Be nice if Geany would have an insert character function.
> (I use Geany as it is ssh X11 friendly.)
>


Re: How do I do literal quotes in a regex?

2019-12-08 Thread ToddAndMargo via perl6-users

On 2019-12-08 18:04, Brad Gilbert wrote:

I do not quite understand the question.

I told you how to directly enter unicode by remembering the codepoint.

It's still the same characters.

I would definitely recommend setting up, and getting used to Compose keys.

I use them all the time for things like « » ‘ ’ “ ” ¹²³⁴⁵⁶⁷⁸⁹⁰¯⁺≠


I was not asking if they were any good or not.

I was asking if you thought someone like me, who
would have to look the them up every time, should
just stick with the what is on the keyboard.

At times I have just had a list of them I could just
copy and paste.

Be nice if Geany would have an insert character function.
(I use Geany as it is ssh X11 friendly.)


Re: How do I do literal quotes in a regex?

2019-12-08 Thread Brad Gilbert
I do not quite understand the question.

I told you how to directly enter unicode by remembering the codepoint.

It's still the same characters.

I would definitely recommend setting up, and getting used to Compose keys.

I use them all the time for things like « » ‘ ’ “ ” ¹²³⁴⁵⁶⁷⁸⁹⁰¯⁺≠

On Sun, Dec 8, 2019 at 6:46 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 2019-12-08 06:22, Brad Gilbert wrote:
> > Personally though I just use 「Ctrl+Shift+u f f 6 2 Space」 and
> > 「Ctrl+Shift+u f f 6 3 Space」
> >
>
> Hi Brad,
>
> Your technical opinion: is it better for maintainability
> to stick with escape sequences or to use the unicodes?
>
> I ask as I will never remember them.  I can only program
> on occasion as I am a jack of all trades.
>
> On the other hand, I currently have 190 keeper files
> (no fooling, I do not liek Raku's documentation) like
> the one I copied in these parts on the hashes.  191
> on unicodes would not hurt.  And I do have to reference
> the other 190 a lot, so it is not like it would be any
> extra work. Although, I an type and when my mind gets
> racing and my fingers can keep up, I really don't
> like to be slowed down.
>
> -T
>


Re: How do I do literal quotes in a regex?

2019-12-08 Thread ToddAndMargo via perl6-users

On 2019-12-08 06:22, Brad Gilbert wrote:
Personally though I just use 「Ctrl+Shift+u f f 6 2 Space」 and 
「Ctrl+Shift+u f f 6 3 Space」




Hi Brad,

Your technical opinion: is it better for maintainability
to stick with escape sequences or to use the unicodes?

I ask as I will never remember them.  I can only program
on occasion as I am a jack of all trades.

On the other hand, I currently have 190 keeper files
(no fooling, I do not liek Raku's documentation) like
the one I copied in these parts on the hashes.  191
on unicodes would not hurt.  And I do have to reference
the other 190 a lot, so it is not like it would be any
extra work. Although, I an type and when my mind gets
racing and my fingers can keep up, I really don't
like to be slowed down.

-T


Re: How do I do literal quotes in a regex?

2019-12-08 Thread ToddAndMargo via perl6-users

On 2019-12-08 08:46, Fernando Santagata wrote:
You won't believe it :-) but Raku's wonderful documentation has a page 
on how to enter Unicode characters:


https://docs.raku.org/language/unicode_entry


Hi Fernando,

Oh they sure do go to town on that one!  That page is
nicely done.

What is the unicode for the subscript double quote „ ?
and can it be used together with the regular
quote the same as 「」 ?

Thank you!

-T

Your take: for maintainability, is it better to use
these unicodes or to just stick with escaping things?


Re: How do I do literal quotes in a regex?

2019-12-08 Thread ToddAndMargo via perl6-users

On 2019-12-08 06:22, Brad Gilbert wrote:


Personally though I just use 「Ctrl+Shift+u f f 6 2 Space」 and 
「Ctrl+Shift+u f f 6 3 Space」


So basically I just remember how to directly type in Unicode codepoints, 
and those the two codepoints.



Taught me something new.  Thank you!


Re: How do I do literal quotes in a regex?

2019-12-08 Thread Fernando Santagata
You won't believe it :-) but Raku's wonderful documentation has a page on
how to enter Unicode characters:

https://docs.raku.org/language/unicode_entry

That page also links to a GitHub project which offers a .XCompose ready to
use.
I started from that and added some faster and easier (for me) to remember
key combinations, such as for example:

   : "「"   UFF62
   : "」"   UFF63

which use the left "Win" key as a dead key, followed by 'l' or 'L' to
produce the Japanese quoting characters.

On Sun, Dec 8, 2019 at 1:56 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

>  > On Sat, Dec 7, 2019 at 12:51 AM ToddAndMargo via perl6-users
>  > mailto:perl6-us...@perl.org>> wrote:
>  >
>  > Hi All,
>  >
>  > Is there a `Q[]` that can be used in a regex?
>  >
>  > I am looking for how to get around
>  >
>  > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ '' /x/; say $y
>  > \:x::
>  >
>  > This does not work:
>  > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ Q[\\] /x/; say $y
>  > \:\\::
>  >
>  > Nor does this:
>  > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ [\\] /x/; say $y
>  > x:\\::
>  >
>  > Many thanks,
>  > -T
>
> On 2019-12-07 07:02, Brad Gilbert wrote:
> > The shortcut spelling of Q[…] is to use 「 and 」 (U+FF62  and U+FF63)
> >
> >  my $x = 「\:\\::」; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y
> >  \:\\::
> >
> > The case could be made that \Q[\\] should work as well. (It would need
> > to be added).
> > (Along with \q[…] and \qq[…])
> >
> > Note that \Q[…] doesn't work in string literals currently either. While
> > \q[…] and \qq[…] do.
> >
> >  > "\q[\n]\n"
> >  \n␤
> >
> >  > '\n\qq[\n]'
> >  \n␤
> >
> > Note that single and double quotes also work in regexs.
> >
> > The three of them ('…' "…" 「…」) have a few jobs.
> >
> > 1. They escape spaces and other non-alphanumerics.
> >
> >  > 'a b c' ~~ / 'a b c' /
> >  Nil
> >  > 'a b c  A B C' ~~ / :i  'a b c' /
> >  A B C
> >
> >  > 'a b c' ~~ / 'a . c' /
> >  Nil
> >  > 'a . c' ~~ / 'a . c' /
> >  a . c
> >
> > Note that the rules for the string literal still apply.
> >
> > > "abc\n" ~~ / 'abc\n' /
> > Nil
> > > "abc\n" ~~ / "abc\n" /
> > abc␤
> >
> > 2. They group characters as a single atom.
> > (Meaning they behave a bit like [] in a regex)
> >
> >  > 'abccd' ~~ / 'abc'+ d /
> >  Nil
> >  > 'abccd' ~~ / [abc]+ d /
> >  Nil
> >
> >  > 'abccd' ~~ / abc+ d /
> >  abccd
> >
> >  > 'abccd   abcABCabcd' ~~ / :i 'abc'+ d /
> >  abcABCabcd
> >  > 'abccd   abcABCabcd' ~~ / :i [abc]+ d /
> >  abcABCabcd
> >
> > Note that '…' in a regex behaves like '…' outside of one, as well as "…"
> > behaving like "…" and 「…」 behaving like 「…」
>
> Hi Brad,
>
>That was above and beyond!  Thank you!
>
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y
> \:x::
>
> What is the easiest way to get those weird brackets in Fedora31?
>
> -T
>


-- 
Fernando Santagata


Re: How do I do literal quotes in a regex?

2019-12-08 Thread Brad Gilbert
I would recommend setting up a compose key.

But that is not enough because I don't think it has a binding for those two
characters.

So you would also have to modify the config to include them.

I think that 「Compose [ [ 」 and 「Compose ] ] 」 might be what I would set
them as.

Note that 「‘」 is 「Compose < ' 」 and  「’」 is 「Compose > ' 」 along with 「“」
and 「”」 being 「Compose < " 」 and 「Compose > " 」



Personally though I just use 「Ctrl+Shift+u f f 6 2 Space」 and 「Ctrl+Shift+u
f f 6 3 Space」

So basically I just remember how to directly type in Unicode codepoints,
and those the two codepoints.

On Sun, Dec 8, 2019 at 6:56 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

>  > On Sat, Dec 7, 2019 at 12:51 AM ToddAndMargo via perl6-users
>  > mailto:perl6-us...@perl.org>> wrote:
>  >
>  > Hi All,
>  >
>  > Is there a `Q[]` that can be used in a regex?
>  >
>  > I am looking for how to get around
>  >
>  > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ '' /x/; say $y
>  > \:x::
>  >
>  > This does not work:
>  > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ Q[\\] /x/; say $y
>  > \:\\::
>  >
>  > Nor does this:
>  > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ [\\] /x/; say $y
>  > x:\\::
>  >
>  > Many thanks,
>  > -T
>
> On 2019-12-07 07:02, Brad Gilbert wrote:
> > The shortcut spelling of Q[…] is to use 「 and 」 (U+FF62  and U+FF63)
> >
> >  my $x = 「\:\\::」; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y
> >  \:\\::
> >
> > The case could be made that \Q[\\] should work as well. (It would need
> > to be added).
> > (Along with \q[…] and \qq[…])
> >
> > Note that \Q[…] doesn't work in string literals currently either. While
> > \q[…] and \qq[…] do.
> >
> >  > "\q[\n]\n"
> >  \n␤
> >
> >  > '\n\qq[\n]'
> >  \n␤
> >
> > Note that single and double quotes also work in regexs.
> >
> > The three of them ('…' "…" 「…」) have a few jobs.
> >
> > 1. They escape spaces and other non-alphanumerics.
> >
> >  > 'a b c' ~~ / 'a b c' /
> >  Nil
> >  > 'a b c  A B C' ~~ / :i  'a b c' /
> >  A B C
> >
> >  > 'a b c' ~~ / 'a . c' /
> >  Nil
> >  > 'a . c' ~~ / 'a . c' /
> >  a . c
> >
> > Note that the rules for the string literal still apply.
> >
> > > "abc\n" ~~ / 'abc\n' /
> > Nil
> > > "abc\n" ~~ / "abc\n" /
> > abc␤
> >
> > 2. They group characters as a single atom.
> > (Meaning they behave a bit like [] in a regex)
> >
> >  > 'abccd' ~~ / 'abc'+ d /
> >  Nil
> >  > 'abccd' ~~ / [abc]+ d /
> >  Nil
> >
> >  > 'abccd' ~~ / abc+ d /
> >  abccd
> >
> >  > 'abccd   abcABCabcd' ~~ / :i 'abc'+ d /
> >  abcABCabcd
> >  > 'abccd   abcABCabcd' ~~ / :i [abc]+ d /
> >  abcABCabcd
> >
> > Note that '…' in a regex behaves like '…' outside of one, as well as "…"
> > behaving like "…" and 「…」 behaving like 「…」
>
> Hi Brad,
>
>That was above and beyond!  Thank you!
>
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y
> \:x::
>
> What is the easiest way to get those weird brackets in Fedora31?
>
> -T
>


Re: How do I do literal quotes in a regex?

2019-12-08 Thread ToddAndMargo via perl6-users

> On Sat, Dec 7, 2019 at 12:51 AM ToddAndMargo via perl6-users
> mailto:perl6-us...@perl.org>> wrote:
>
> Hi All,
>
> Is there a `Q[]` that can be used in a regex?
>
> I am looking for how to get around
>
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ '' /x/; say $y
> \:x::
>
> This does not work:
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ Q[\\] /x/; say $y
> \:\\::
>
> Nor does this:
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ [\\] /x/; say $y
> x:\\::
>
> Many thanks,
> -T

On 2019-12-07 07:02, Brad Gilbert wrote:

The shortcut spelling of Q[…] is to use 「 and 」 (U+FF62  and U+FF63)

     my $x = 「\:\\::」; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y
     \:\\::

The case could be made that \Q[\\] should work as well. (It would need 
to be added).

(Along with \q[…] and \qq[…])

Note that \Q[…] doesn't work in string literals currently either. While 
\q[…] and \qq[…] do.


     > "\q[\n]\n"
     \n␤

     > '\n\qq[\n]'
     \n␤

Note that single and double quotes also work in regexs.

The three of them ('…' "…" 「…」) have a few jobs.

1. They escape spaces and other non-alphanumerics.

     > 'a     b c' ~~ / 'a b c' /
     Nil
     > 'a     b c  A B C' ~~ / :i  'a b c' /
     A B C

     > 'a b c' ~~ / 'a . c' /
     Nil
     > 'a . c' ~~ / 'a . c' /
     a . c

Note that the rules for the string literal still apply.

    > "abc\n" ~~ / 'abc\n' /
    Nil
    > "abc\n" ~~ / "abc\n" /
    abc␤

2. They group characters as a single atom.
(Meaning they behave a bit like [] in a regex)

     > 'abccd' ~~ / 'abc'+ d /
     Nil
     > 'abccd' ~~ / [abc]+ d /
     Nil

     > 'abccd' ~~ / abc+ d /
     abccd

     > 'abccd   abcABCabcd' ~~ / :i 'abc'+ d /
     abcABCabcd
     > 'abccd   abcABCabcd' ~~ / :i [abc]+ d /
     abcABCabcd

Note that '…' in a regex behaves like '…' outside of one, as well as "…" 
behaving like "…" and 「…」 behaving like 「…」


Hi Brad,

  That was above and beyond!  Thank you!

my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y
\:x::

   What is the easiest way to get those weird brackets in Fedora31?

-T


Re: How do I do literal quotes in a regex?

2019-12-07 Thread Brad Gilbert
The shortcut spelling of Q[…] is to use 「 and 」 (U+FF62  and U+FF63)

my $x = 「\:\\::」; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y
\:\\::

The case could be made that \Q[\\] should work as well. (It would need to
be added).
(Along with \q[…] and \qq[…])

Note that \Q[…] doesn't work in string literals currently either. While
\q[…] and \qq[…] do.

> "\q[\n]\n"
\n␤

> '\n\qq[\n]'
\n␤

Note that single and double quotes also work in regexs.

The three of them ('…' "…" 「…」) have a few jobs.

1. They escape spaces and other non-alphanumerics.

> 'a b c' ~~ / 'a b c' /
Nil
> 'a b c  A B C' ~~ / :i  'a b c' /
A B C

> 'a b c' ~~ / 'a . c' /
Nil
> 'a . c' ~~ / 'a . c' /
a . c

Note that the rules for the string literal still apply.

   > "abc\n" ~~ / 'abc\n' /
   Nil
   > "abc\n" ~~ / "abc\n" /
   abc␤

2. They group characters as a single atom.
(Meaning they behave a bit like [] in a regex)

> 'abccd' ~~ / 'abc'+ d /
Nil
> 'abccd' ~~ / [abc]+ d /
Nil

> 'abccd' ~~ / abc+ d /
abccd

> 'abccd   abcABCabcd' ~~ / :i 'abc'+ d /
abcABCabcd
> 'abccd   abcABCabcd' ~~ / :i [abc]+ d /
abcABCabcd

Note that '…' in a regex behaves like '…' outside of one, as well as "…"
behaving like "…" and 「…」 behaving like 「…」


On Sat, Dec 7, 2019 at 12:51 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> Is there a `Q[]` that can be used in a regex?
>
> I am looking for how to get around
>
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ '' /x/; say $y
> \:x::
>
> This does not work:
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ Q[\\] /x/; say $y
> \:\\::
>
> Nor does this:
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ [\\] /x/; say $y
> x:\\::
>
> Many thanks,
> -T
>


How do I do literal quotes in a regex?

2019-12-06 Thread ToddAndMargo via perl6-users

Hi All,

Is there a `Q[]` that can be used in a regex?

I am looking for how to get around

my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ '' /x/; say $y
\:x::

This does not work:
my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ Q[\\] /x/; say $y
\:\\::

Nor does this:
my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ [\\] /x/; say $y
x:\\::

Many thanks,
-T