[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NON-trivial regular expression problem (could not find on google)
From: |
Kai Großjohann |
Subject: |
Re: NON-trivial regular expression problem (could not find on google) |
Date: |
Sat, 18 Jan 2003 22:46:58 +0100 |
User-agent: |
Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.3.50 (i686-pc-linux-gnu) |
democrat@india.com (Instant Democracy) writes:
> 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.
Let s be a string such as the above, but without quotes. Then
(expand-file-name s "/")
will return a suitable string, except that it starts with slash.
So in Emacs Lisp, you can do it without regular expressions, but in
three steps:
(1) Remove quotes
(2) Above Lisp expression
(3) Remove leading slash
In Emacs, regular expressions are often not the answer.
--
Ambibibentists unite!
- NON-trivial regular expression problem (could not find on google), Instant Democracy, 2003/01/18
- Re: NON-trivial regular expression problem (could not find on google), Harry Putnam, 2003/01/18
- Re: NON-trivial regular expression problem (could not find on google),
Kai Großjohann <=
- Re: NON-trivial regular expression problem (could not find on google), AW, 2003/01/18
- Re: NON-trivial regular expression problem (could not find on google), Edi Weitz, 2003/01/18
- Re: NON-trivial regular expression problem (could not find on google), Larry Clapp, 2003/01/18
- Re: NON-trivial regular expression problem (could not find on google), Dr. Yuan Liu, 2003/01/18
- Re: NON-trivial regular expression problem (could not find on google), John W. Krahn, 2003/01/18
- Re: NON-trivial regular expression problem (could not find on google), William Park, 2003/01/18
- Re: NON-trivial regular expression problem (could not find on google), Peter J. Acklam, 2003/01/19