Concerning the condition
* MATCH ?? ^^\/.+($.*[^ ])*
Ralph SOBEK asked, in response to my last note:
Actually, does the above only eliminate terminal white-space and NLs
*only* at the very end of whatever MATCH found? Also, does this
conditon always succeed?
While I replied directly to him, the following clarification might be
generally useful. It includes a correction as well.
Here is my parse (trust the code, not the comments):
* MATCH ?? Compare the contents of MATCH
^^\/ create a new MATCH from the beginning
.+ require at least one character
( )* followed by zero or more repetitions of
$.* a newline and a sequence of chars
[^ ] ending with a non-whitespace char
Comments:
If MATCH is empty, this will fail (it requires at least one
character). Therefore, use this only with a matching recipe which
returns a non-empty MATCH.
If MATCH contains only a newline, it will return the newline. This is
a problem if the regexp which generated the MATCH can generate a
single newline.
The key thing to recognize is that + and * are greedy to the right of
a \/. This means that the regexp matches as many lines as possible.
If the last line is the only line, the resulting MATCH will include
trailing whitespace. If the last line is not the only line, the
resulting MATCH will have as many characters as possible up to the
final non-whitespace character. To eliminate trailing whitespace on a
one-line result, this may work (untested). I'm in the middle of a
conference session and can't really test it yet. I hope that our
resident experts will correct this if it is wrong.
* MATCH ?? ^^\/.+[^ ]*([ ]*$[^ ])*
If you need trailing spaces on the last line matched, SMOP.
--
Rik Kabel Old enough to be an adult
rik(_at_)netcom(_dot_)com