procmail
[Top] [All Lists]

Re: how to strip any leading and trailing whitespaces?

2000-03-15 02:23:15
On Tue, Mar 14, 2000 at 10:19:35AM -0600, David W. Tamkin wrote:

Hi David.

[skipped]

However expensive formail is, one formail is less costly than a formail, two
seds, an expand, and a shell to pipe each to the next, and at that point you
still haven't filtered the message to have the stripped subject line.  As in

It's clear.

your own code, brackets enclose space and tab or caret, space, and tab:

  :0fwh # second asterisk and question mark are greedy
  * ^Subject:[        ]*\/[^  ](.*[^  ])?
  | formail -I "Subject: $MATCH"
  :0Efwh
  * ^Subject:
  | formail -I "Subject: (was blank)"
  :0Efwh
  | formail -I "Subject: (was missing)"

Of course, that will be fooled if an incoming subject really is "(was blank)"
or "(was missing)," but I think the risk is negligible.

But to avoid this I can write something like this:

:0 fwh
* 1^0 ^Subject:([       ]$|$)
| formail -I "Subject: (was blank)"

:0 E fwh
* 1^0 !^Subject:
| formail -I "Subject: (was missing)"

:0 E fwh
* ^Subject:[    ]*\/[^  ](.*[^  ])?
| formail -I "Subject: ${MATCH}"

Right?

And I have two more questions.
In '^Subject:([         ]$|$)' ([       ]$|$) means any quantity of
whitespaces and tabs or new line which follows right after the Subject:
header?

In '^Subject:[  ]*\/[^  ](.*[^  ])?' [^         ](.*[^  ])? means
any symbols which don't start with any quantity of whitespaces and tabs
and don't trail with the same ones'?

Then I wanna strip any dashes, whitespaces, tabs, slashes, backslashes,
semicolons, colons, commas etc. from the subject e. g. to leave characters and
digits only.

.....

:0 E fwh
* ^Subject:[    ]*\/[^  ](.*[^  ])?
| formail -I "Subject: ${MATCH}"

:0 a fwh
* ^Subject:[    ]*\/[A-Za-z0-9]+
| formail -I "Subject: ${MATCH}"

Right?

Thank you for any help.

---
Can't Rain All the Time

<Prev in Thread] Current Thread [Next in Thread>