procmail
[Top] [All Lists]

how to strip any leading and trailing whitespaces?

2000-03-14 06:24:50
Hi there,

How may I discard any leading and trailing whitespaces from Subject?
I have the following recipe:

:0 hc
* ^Subject:[    ]*\/[^  ].*   # [ ] contain space and tab
| sed -e 's/[;\`\\]/ /g' | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'
SUBJECT = ${MATCH}

Any leading whitespaces are stripped by this recipe but trailing ones'
aren't.
The following recipe works fine for me:

:0
 { SUBJECT=`formail -xSubject: |  sed -e 's/[;\`\\]/ /g' |\
        expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'` }

but I read formail's calls were too expensive and slowed down the system.
I wanna do it using procmail's MATCH variable.

Thanks for any help.

---
Can't Rain All the Time

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