Is there a number class in regex? [SOLVED]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

Is there a number class in regex? [SOLVED]

#1 Post by musher0 »

Hello all.

As the title says: "Is there a number class in regex?" A "class" or
whatever it may be called.

regex has a class for ::word:: but I couldn't find one for digits.
(Or maybe I need new glasses?!)

It's not a big problem, it's efficient as it is written, but I would like to
compact the list of numbers in the following line:

Code: Select all

cd PupMenu
ls -Algo --file-type ./* | awk '{ print $NF }' | grep -E -v "^0|^1|^2|^3|^4|^5|^6|^7|^8|^9|~|^_|oris\/|ites\/" > ../aewm-menu.lst
This:

Code: Select all

"^[0-9]|~|^_|oris\/|ites\/" > ../aewm-menu.lst
does NOT work. It creates an almost empty menu, it seems to skip all
entries that come afterwards.

The full script is attached as a zip. The goal is to recreate an aemenu
from the wmx menu.

Thanks in advance for any pointers.

~~~~~~~~~~
PS -- Please don't mind the silly variable names and file names. I was
tired when I wrote the script.
Attachments
pifpag.sh.zip
(1023 Bytes) Downloaded 110 times
Last edited by musher0 on Wed 04 Jan 2017, 15:07, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#2 Post by LazY Puppy »

I was tired when I wrote the script.
Aren't we (almost) all somehow tired when we do write scripts?

Probably we would program in C or similar Programming Language if we wouldn't be that much tired?
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

Funny guy! ;)

As to writing in C, the bash script is as respectable, you know.

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: Is there a number class in regex?

#4 Post by MochiMoppel »

musher0 wrote:This:

Code: Select all

"^[0-9]|~|^_|oris\/|ites\/" > ../aewm-menu.lst
does NOT work.
It works for me.

If your grep version recognizes POSIX bracket expressions you could, instead of grep -E -v "^[0-9]", use grep -E -v "^[[:digit:]]", but that would be less compact...

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#5 Post by musher0 »

Ah. Thank you very much, MochiMoppei. Very helpful.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply