procmail
[Top] [All Lists]

Re: Eliminating Linefeed embedded in a $MATCH result

1999-04-29 13:05:13
Ralph Sobek asked,

| What is the best method to eliminate embedded linefeeds?
| Otherwise, how to limit a $MATCH to just a single line?

The second question is much easier to answer than the first.  If you had a
multiline match and wanted to strip out the newlines, I can't think of
anything other than feeding the value of $MATCH to tr.  But I'm going to read
your post as wanting to strip a trailing newline from a single-line match.

| I currently have conditions like:
|
|       * B ?? ()\/\<Foobars?\>

Apparently \> is matching to the newline.

| If "Foobar" is at the end of the line, $MATCH contains a linefeed.  Do
| I have to add ".*$" at the end, to limit it to just the considered
| line?

No, that won't help, because "$" will match on the newline.

Suggestion: if your procmail version is new enough to be able to rematch
within a condition (if it isn't, upgrade),

        * B ?? ()\/\<Foobars?\>
        * MATCH ?? ^^\/.+

"." will match anything except a newline.

If it isn't and you can't upgrade, try Era's suggestion; there is yet another
way, but what Era has posted is better.