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