From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: democrat@india.com (Instant Democracy) Newsgroups: gmane.emacs.help Subject: NON-trivial regular expression problem (could not find on google) Date: 18 Jan 2003 12:19:24 -0800 Organization: http://groups.google.com/ Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <7606630f.0301181219.60384da2@posting.google.com> NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1042921223 17873 80.91.224.249 (18 Jan 2003 20:20:23 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 18 Jan 2003 20:20:23 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18ZzRy-0004e0-00 for ; Sat, 18 Jan 2003 21:20:19 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18ZzSS-0004Cv-06 for gnu-help-gnu-emacs@m.gmane.org; Sat, 18 Jan 2003 15:20:48 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail Original-Newsgroups: comp.lang.lisp,comp.lang.awk,comp.unix.shell,gnu.emacs.help Original-Lines: 130 Original-NNTP-Posting-Host: 209.179.41.115 Original-X-Trace: posting.google.com 1042921164 26893 127.0.0.1 (18 Jan 2003 20:19:24 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: 18 Jan 2003 20:19:24 GMT Original-Xref: shelby.stanford.edu comp.lang.lisp:103178 comp.lang.awk:24424 comp.unix.shell:139860 gnu.emacs.help:109137 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:5664 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5664 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. >