help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NON-trivial regular expression problem (could not find on google)


From: Instant Democracy
Subject: NON-trivial regular expression problem (could not find on google)
Date: 18 Jan 2003 12:19:24 -0800

Regular expression facilities are slightly varied in
sed
awk
lisp
emacs-lisp
Therefore these newsgroups can all contribute to the discussion.

A frequent problem involves simplifying a pathname. The string format we
can expect to encounter is covered by the following three examples:

"dir.name/../dir/../file"
"dir/../d2/../file.ext"
"d1/d2/../../file.ext"

The "" are part of the string, and not just string delimiters. These
strings are inside regular text on the line. The paths are never
absolute so that you will not encounter "/d1/file.ext".

The task is to eliminate patterns such as 
    DIRNAME/../
from the path because they are redundant.

For lines which do not have ../.. in them, this is
trivial, for example by regexp in sed, emacs etc.

The real problem is constructing a regular expression for
the DIRNAME before the /..

This DIRNAME can be described as a string that contains neither
/ not double-dot but anything else. Perhaps I am overlooking
something else about DIRNAME.

The regular expression for the first two cases is demonstrated by this
sed script although the lisp variants are identical.

sed 's,\(^.*\)\(/\|"\)\([^/][^/]*/\.\./\)\(.*"\),\1\2\4,'

The regex I use for DIRNAME is [^/]+ written above using * because
sed is without plus.

I will follow all the cross-posted newsgroups. If you prefer, because
some people are allergic to any cross-posting, you can post your reply
in just one of the groups pertaining to your application, ie lisp/elisp/sed/awk.

democrat

sigfile - you are welcome to use it or modify without changing its thrust.
>
> US DEMONCRACY IS FLAWED - THE SOLUTION FOR TODAY IS HERE
> 
> THE ECONOMY CAN BE KICK-STARTED BY LAYING OFF THE
> POLITICIANS AND REDUCING THEIR SALARIES BY 60%
> 
> What do we have today? A faulty plutocracy that was
> designed in an age that had no electricity, no
> electronics, no internet and no mass media. It was in a
> barbaric age of slavery and bigotry.  The people were so
> illiterate that they even failed to understand what they
> wrote in the constitution - otherwise there would be no
> slavery side by side with "... all men are created equal
> ...."
> 
> The reason for world-wide wars is corruption, and
> plutocracy. The power of criminal rulers is not being
> checked properly by that of the people.  There is too
> much effort to bring down a corrupt leader. For example,
> Clinton managed to lollypop a number of women before he
> was caught.  The child molesters in the church were not
> caught for a greater part of their life-time. But make
> no mistake, those who are caught are the unskilled
> ones. The highly skilled criminals like Bush and his ilk
> are not going to be caught in their life-time, so
> cleverly have they concealed their ill deeds.
> 
> The plutocrats are pathetic. The senators, congressmen
> and presidents failed to eliminate slavery and there is
> no justification to pay them high salaries to the tune
> of $500,000 per year and then the retirements, perks,
> security.
> 
> It happened on the battle field because plutocrats would
> not allow people's wishes to be translated into action.
> 
> Today, we are way behind times.
> 
> There is no need for a president, electoral college,
> congressmen and senators.
> 
> What is needed are state messengers and clerks. The
> public would vote weekly by telephone from their home to
> an electronic computer. Enter their password and vote on
> an issue. All can be made secure by multiple redundancy
> and open source code and interpreter that can be run on
> any PC. All voting is to be open and everyone can check
> cheating. If our medical records are going to be open,
> it is but little that all voting on issues is open and
> everyone can check their own voting with confirmation.
> 
> Just as we are secure with our bank accounts and check
> our balance by phone, we can vote on issues.
> 
> All issues can be discussed by internet, phone, and so
> on to educate the public.
> 
> But the senators, congressmen and presidents are
> corrupt, unfaithful even to their wives, take too much
> money for salary for a work executed pathetically. Some
> president are doing affairs, others are moral quacks
> with basic errors in english grammar and also
> intellectual and personality wise, midgets.
> 
> This is an age of instant telephone referendum and
> instant democracy.
> 
> The power to wage war should neither belong to the
> president, nor to the congress, but to the people via
> instant referendum.
> 
> The electoral college is also a dinosaur. Americans are
> educated enough to decide who to choose as a referendum
> executioner, that is, the president.
> 
> This is not a third world country, with slavery, no
> electricity, no media, no railway, no steam engine, no
> satellites, no telephone that we must not have instant
> democracy.
> 
> What we have today is not democracy, but demoncracy of a
> few.
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]