words and separators question

Hi All,

I have a situation where I can see two different strings:

     "xxx      yyyy       zzz"
     "avcde    fg hi      jklmx"

"fg hi" only has one space in the middle.

All the words have multiple spaces between them.

Is there a way I can tell words that I want "fg hi" to
be considered one word?  A way to make the separator
two or more spaces?

Many thanks,
-T
0
perl6
11/28/2019 1:51:15 PM
perl.perl6.users 1249 articles. 0 followers. Follow

4 Replies
6 Views

Similar Articles

[PageSpeed] 8

--0000000000004247cf059869323f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, Nov 28, 2019 at 2:53 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Is there a way I can tell words that I want "fg hi" to
> be considered one word?  A way to make the separator
> two or more spaces?
>

  I don't think you can pass a separator to words.   But you can specify a
separator with split:  I assume .split(/\s\s+/) will DWYW.

  =E2=80=A6 or .comb(/\S[\s?\S]+/) =E2=80=A6 obviously not a very readable =
choice in this
instance, mind =E2=80=A6


Eirik

--0000000000004247cf059869323f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Thu, Nov 28, 2019 at 2:53 PM ToddA=
ndMargo via perl6-users &lt;<a href=3D"mailto:perl6-users@perl.org">perl6-u=
sers@perl.org</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi=
ng-left:1ex">
Is there a way I can tell words that I want &quot;fg hi&quot; to<br>
be considered one word?=C2=A0 A way to make the separator<br>
two or more spaces?<br></blockquote><div><br></div><div>=C2=A0 I don&#39;t =
think you can pass a separator to words. =C2=A0 But you can specify a separ=
ator with split:=C2=A0 I assume .split(/\s\s+/) will DWYW.<br></div><div><b=
r></div><div>=C2=A0 =E2=80=A6 or=C2=A0.comb(/\S[\s?\S]+/) =E2=80=A6 obvious=
ly not a very readable choice in this instance, mind =E2=80=A6<br></div><di=
v><br></div><div><br></div><div>Eirik<br></div></div></div>

--0000000000004247cf059869323f--
0
sidhekin
11/28/2019 2:47:33 PM
On 2019-11-28 05:51, ToddAndMargo via perl6-users wrote:
> Hi All,
>=20
> I have a situation where I can see two different strings:
>=20
>  =C2=A0=C2=A0=C2=A0 "xxx=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 yyyy=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 zzz"
>  =C2=A0=C2=A0=C2=A0 "avcde=C2=A0=C2=A0=C2=A0 fg hi=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 jklmx"
>=20
> "fg hi" only has one space in the middle.
>=20
> All the words have multiple spaces between them.
>=20
> Is there a way I can tell words that I want "fg hi" to
> be considered one word?=C2=A0 A way to make the separator
> two or more spaces?
>=20
> Many thanks,
> -T


This is the actual command I am dealing with.  This
command gived me a partition's UUID (DeviceID), the
partition's label (Label), and the drive letter (Name).
Note: the name of an unmounted drive is its UUID:


C:\NtUtil>wmic.exe volume get deviceid,label,name
DeviceID                                           Label             Name=


\\?\Volume{c9b182e9-96a0-11e2-9a72-806e6f6e6963}\  System Reserved=20
\\?\Volume{
c9b182e9-96a0-11e2-9a72-806e6f6e6963}\

\\?\Volume{e20f10e6-6b04-4748-b7b8-2704997af1f1}\  KVM-W7-Backup     M:\

\\?\Volume{c9b182ea-96a0-11e2-9a72-806e6f6e6963}\  DRIVE_C           C:\

\\?\Volume{5efeb388-02e8-11e8-9297-806e6f6e6963}\                    D:\

\\?\Volume{4084e22f-03c2-11e9-bb20-806e6f6e6963}\  virtio-win-0.1.1  E:\


You will notice that "System Reverved" is the item with
a space in it.

And, that the positioning is different for Windwos 7
and Windows 10:

    $DeviceID =3D $Line.substr(0..48);

    # w7
    # $Label    =3D $Line.substr(51..66);
    # $Name     =3D $Line.substr(69..71);

    # w10
    $Label    =3D $Line.substr(51..58).trim;
    $Name     =3D $Line.substr(61..63);

or I would just cut out what I needed.

Now I can check which version of Wndows I am in, but
I wanted to make it seamless such that I constantly
did not have to check Windows version.  (W10 gets a
new build every six months.)

I suppose I could extract the UUID amd then erase it
from the stinng, the extract everything starting
with a double space to the Name and remove it from
the string.  Trim what was left and that would
be the Label.  Hmmmmm  Seems to me Perl has though
of a way around this already.
0
perl6
11/29/2019 3:04:57 AM
On 2019-11-28 06:47, The Sidhekin wrote:
>=20
>=20
> On Thu, Nov 28, 2019 at 2:53 PM ToddAndMargo via perl6-users=20
> <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote:
>=20
>     Is there a way I can tell words that I want "fg hi" to
>     be considered one word?=C2=A0 A way to make the separator
>     two or more spaces?
>=20
>=20
>  =C2=A0 I don't think you can pass a separator to words. =C2=A0 But you=
 can=20
> specify a separator with split:=C2=A0 I assume .split(/\s\s+/) will DWY=
W.
>=20
>  =C2=A0 =E2=80=A6 or=C2=A0.comb(/\S[\s?\S]+/) =E2=80=A6 obviously not a=
 very readable choice in=20
> this instance, mind =E2=80=A6
>=20
>=20
> Eirik


Hi Eirik,

Thank you!.  I will play with it!

-T
0
perl6
11/29/2019 3:14:57 AM
On 2019-11-28 05:51, ToddAndMargo via perl6-users wrote:
> Hi All,
>=20
> I have a situation where I can see two different strings:
>=20
>  =C2=A0=C2=A0=C2=A0 "xxx=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 yyyy=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 zzz"
>  =C2=A0=C2=A0=C2=A0 "avcde=C2=A0=C2=A0=C2=A0 fg hi=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 jklmx"
>=20
> "fg hi" only has one space in the middle.
>=20
> All the words have multiple spaces between them.
>=20
> Is there a way I can tell words that I want "fg hi" to
> be considered one word?=C2=A0 A way to make the separator
> two or more spaces?
>=20
> Many thanks,
> -T


Follow up:

Silly me.  Just use m/

     @RtnAry =3D qx ( wmic.exe volume get deviceid,label,name  ).lines;
     for @RtnAry.kv -> $I, $Line {
          if  $Line.chars =3D=3D 0  { next; };
          # say $Line;

          $Line ~~ m/ (.*?) "  " (.*?) "  " (.*) /;
          # say "<" ~ "$0" ~ ">" ~ "\n";
          %LineHash<UUID>        =3D $0;
          %LineHash<Label>       =3D $1;
          %LineHash<DriveLetter> =3D $2;

          %LineHash<Label>       =3D %LineHash<Label>.trim;
          %LineHash<DriveLetter> =3D %LineHash<DriveLetter>.trim;

          %LineHash<UUID> ~~ s| .*? '\\' |\\|;  # dump the wierd =E2=88=A9=
=E2=95=9C=C3=B3 prefix
          if  not %LineHash<DriveLetter>.contains( ":" )  {=20
%LineHash<DriveLetter> =3D "" }

          # say %LineHash ~ "\n";
          push( @Partitions, %LineHash );
          # say %LineHash<UUID> ~ "  " ~ %LineHash<Label> ~ "  " ~=20
%LineHash<DriveLetter> ~ "\n";
          # say @Partitions[ $I ];
     }
0
perl6
11/30/2019 5:09:43 AM
Reply: