From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "John W. Krahn" Newsgroups: gmane.emacs.help Subject: Re: NON-trivial regular expression problem (could not find on google) Date: Sun, 19 Jan 2003 00:53:45 GMT Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3E29F6D3.30FBC51B@acm.org> References: <7606630f.0301181219.60384da2@posting.google.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1042937774 28527 80.91.224.249 (19 Jan 2003 00:56:14 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 19 Jan 2003 00:56:14 +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 18a3ky-0007Pq-00 for ; Sun, 19 Jan 2003 01:56:12 +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 18a3kO-0002Wt-01 for gnu-help-gnu-emacs@m.gmane.org; Sat, 18 Jan 2003 19:55:36 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!xmission!newsfeed.telusplanet.net!news1.telusplanet.net.POSTED!53ab2750!not-for-mail X-Mailer: Mozilla 4.79 [en] (X11; U; Linux 2.4.4-4GB i586) X-Accept-Language: en Original-Newsgroups: comp.lang.lisp,comp.lang.awk,comp.unix.shell,gnu.emacs.help Original-Lines: 54 Original-NNTP-Posting-Host: 64.180.179.194 Original-X-Trace: news1.telusplanet.net 1042937625 64.180.179.194 (Sat, 18 Jan 2003 17:53:45 MST) Original-NNTP-Posting-Date: Sat, 18 Jan 2003 17:53:45 MST Original-Xref: shelby.stanford.edu comp.lang.lisp:103190 comp.lang.awk:24434 comp.unix.shell:139875 gnu.emacs.help:109162 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:5686 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5686 Instant Democracy wrote: > > 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. $ perl -le' @paths = qw( "dir.name/../dir/../file" "dir/../d2/../file.ext" "d1/d2/../../file.ext" "../../../file" ); for ( @paths ) { print; s%([^"]+)% local $_ = $1; 1 while s|[^/]+(?