LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   regexp (https://www.linuxquestions.org/questions/linux-software-2/regexp-415780/)

stomach 02-15-2006 01:12 PM

regexp
 
Condition "OR" is represented with "|".
Code:

/^.*param|param2/
How I make command "AND" with regexp? Or either to enter in the necessary filter to have all the parametros in any place in the body of the email.

Code:

PARAM1 "AND" STOP "AND" PARAM2

macemoneta 02-15-2006 02:49 PM

A logical and is usually performed by multiple stages. For example:

grep "PARAM1" | grep "STOP" | grep "PARAM2"

That is, in order to make it to the successive stages, the requirements of the preceding stages must have been satisfied.

stomach 02-15-2006 02:55 PM

These parameters are for rejecting email in postfix.
/etc/postfix/body_checkes

grep in regexp?

macemoneta 02-15-2006 05:06 PM

Sorry, your question was on regular expressions, not postfix configuration. Perhaps someone familiar with postfix filtering can address this...

Tinkster 02-15-2006 05:26 PM

Quote:

Originally Posted by stomach
Condition "OR" is represented with "|".
Code:

/^.*param|param2/
How I make command "AND" with regexp? Or either to enter in the necessary filter to have all the parametros in any place in the body of the email.

Code:

PARAM1 "AND" STOP "AND" PARAM2

Ummm ... if they come in the same sequence I don't
see the problem ...

Code:

PARAM1.*STOP .*PARAM2

Cheers,
Tink

stomach 02-15-2006 06:09 PM

the problem is that the necessary message is orderly.
example:
Code:

PARAM1.*STOP .*PARAM2

Code:

testing message PARAM1 and PARAM2.
It functions perfectly!


But if I to modify the message it stops:
Code:

testing message PARAM2 and PARAM1.
It does not go to function

Tinkster 02-15-2006 06:25 PM

In that case you will have to bite the bullet and do something
very ugly (if the repeated greps are not an option):
Quote:

egrep "(PARAM1.*PARAM2|PARAM2.*PARAM1)"
This would (quite obviously) become very verbose with more parameters,
so a repeated grep is probably the better choice.


Cheers,
Tink

stomach 02-15-2006 06:33 PM

thank you Tinkster.


All times are GMT -5. The time now is 09:49 AM.