Subject Regular expressión

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Subject Regular expressión

Emanuel
Hello,

I have a problem when locking with regular expressions

I need match

/^Subject: (Hello there(.*)|Hey man(.*))/ discard

The rule not work.!

the parameter. * is correct?

any ideas?

thanks for your help.

--
Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Phil Stracchino
On 04/10/18 13:00, Emanuel wrote:

> Hello,
>
> I have a problem when locking with regular expressions
>
> I need match
>
> /^Subject: (Hello there(.*)|Hey man(.*))/ discard
>
> The rule not work.!
>
> the parameter. * is correct?
>
> any ideas?

Well to start with, in that regex, both (.*) sub-expressions are
completely redundant.  But you may be making too many assumptions about
whitespace.  Your version will work only if there is *precisely one
space and nothing else* between 'Subject:' and the text.

Try this:

/^Subject:.*(Hello there|Hey man)/    DISCARD



--
  Phil Stracchino
  Babylon Communications
  [hidden email]
  [hidden email]
  Landline: +1.603.293.8485
  Mobile:   +1.603.998.6958
Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Viktor Dukhovni


> On Apr 10, 2018, at 1:50 PM, Phil Stracchino <[hidden email]> wrote:
>
> /^Subject:.*(Hello there|Hey man)/    DISCARD

Can't say I'd recommend discarding email on such tenuous grounds, but if that's one wants:

    header-checks.pcre:
        # One if...endif block per header, here just for "Subject:"
        # Each block ends with: /^/ DUNNO, short-circuiting any further
        # rules for any other headers.  So we first find the right header
        # block, then the right rule for that header.
        #
        if /^Subject:/
        /\bHello there/ DISCARD
        /\bHey man/ DISCARD
        # ... More subject- rules here ...
        /^/ DUNNO
        endif

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Stephen Satchell
In reply to this post by Emanuel
On 04/10/2018 10:00 AM, Emanuel wrote:
> Hello,
>
> I have a problem when locking with regular expressions
>
> I need match
>
> /^Subject: (Hello there(.*)|Hey man(.*))/ discard

Break it up into two separate entries.  There is little cost in doing so.

The | operator is supposed to bind to a single token before and after.
What I do in such situations is enclose the substrings on each side of
the | in parens.

As pointed out by another member here the trailing ".*" is unnecessary.

Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Dominic Raferd
On 11 April 2018 at 01:24, Stephen Satchell <[hidden email]> wrote:
The | operator is supposed to bind to a single token before and after.

​Not true - at least for pcre. Just enclose the entire expression in brackets:

/^Subject:\s*(Hello there|Hey man)/ DISCARD

(However Viktor's suggestion is more flexible/extendable.)
Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Olivier Nicole-2
Dominic Raferd <[hidden email]> writes:

> [1:text/plain Show]
>
>
> [2:text/html Hide Save:noname (6kB)]
>
> On 11 April 2018 at 01:24, Stephen Satchell <[hidden email]> wrote:
>
>  The | operator is supposed to bind to a single token before and after.
>
> ​Not true - at least for pcre. Just enclose the entire expression in brackets:
>
> ​
> ​/^Subject:\s*(Hello there|Hey man)/ DISCARD
>
> (However Viktor's suggestion is more flexible/extendable.)

I'll never praise that tool enough, for Perl regex, it saved my bacon
more often than not: The Regex Coach (http://weitz.de/regex-coach/)

It works fine under wine.

In fact, this morning I wrote a regex using the regex coach, so I could
see what it did as long as I was writing it.

Best s,

Olivier
--
Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Emanuel
In reply to this post by Dominic Raferd

to apply a limit to the url??

{64}.* (your linked profile)/

it's correct this rule?


El 11/04/18 a las 02:59, Dominic Raferd escribió:
On 11 April 2018 at 01:24, Stephen Satchell <[hidden email]> wrote:
The | operator is supposed to bind to a single token before and after.

​Not true - at least for pcre. Just enclose the entire expression in brackets:

/^Subject:\s*(Hello there|Hey man)/ DISCARD

(However Viktor's suggestion is more flexible/extendable.)

--
Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Viktor Dukhovni


> On Apr 17, 2018, at 12:22 PM, Emanuel <[hidden email]> wrote:
>
> to apply a limit to the url??
>
> {64}.* (your linked profile)/
>
> it's correct this rule?

The above is much too cryptic.  Perhaps you can state a clear goal and a more precise question.

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Emanuel

my idea is to limit the possibilities of the regular expression

by indicating only * there is an infinite number of possibilities

I've been having no luck with a simple regex to match strings with 64 or less characters.

Regards,


El 17/04/18 a las 13:56, Viktor Dukhovni escribió:

On Apr 17, 2018, at 12:22 PM, Emanuel [hidden email] wrote:

to apply a limit to the url??

{64}.* (your linked profile)/

it's correct this rule?
The above is much too cryptic.  Perhaps you can state a clear goal and a more precise question.


--
envialosimple.com
Emanuel Gonzalez
IT / Departamento Emails
[hidden email]
www.envialosimple.com
by donweb
 
Nota de confidencialidad: Este mensaje y archivos adjuntos al mismo son confidenciales, de uso exclusivo para el destinatario del mismo. La divulgación y/o uso del mismo sin autorización por parte de DonWeb.com queda prohibida.
DonWeb.com no se hace responsable del mensaje por la falsificación y/o alteración del mismo.
De no ser Ud el destinatario del mismo y lo ha recibido por error, por favor, notifique al remitente y elimínelo de su sistema.
Confidentiality Note: This message and any attachments (the message) are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited by DonWeb.com.
DonWeb.com shall not be liable  for the message if altered or falsified.
If you are not the intended addressee of this message, please cancel it immediately and inform the sender
Nota de Confidencialidade: Esta mensagem e seus eventuais anexos podem conter dados confidenciais ou privilegiados.
Se você os recebeu por engano ou não é um dos destinatários aos quais ela foi endereçada, por favor destrua-a e a todos os seus eventuais anexos ou copias realizadas, imediatamente.
É proibida a retenção, distribuição, divulgação ou utilização de quaisquer informações aqui contidas.
Por favor, informenos sobre o recebimento indevido desta mensagem, retornando-a para o autor.
 
Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Phil Stracchino
On 04/17/18 13:33, Emanuel wrote:
> my idea is to limit the possibilities of the regular expression
>
> by indicating only * there is an infinite number of possibilities
>
> I've been having no luck with a simple regex to match strings with 64 or
> less characters.

In a Perl-compatible regular expression, you want something like this:

/.{,64}(your linked profile)/



--
  Phil Stracchino
  Babylon Communications
  [hidden email]
  [hidden email]
  Landline: +1.603.293.8485
  Mobile:   +1.603.998.6958
Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Viktor Dukhovni


> On Apr 17, 2018, at 1:39 PM, Phil Stracchino <[hidden email]> wrote:
>
> In a Perl-compatible regular expression, you want something like this:
>
> /.{,64}(your linked profile)/

Which (when used verbatim) is equivalent to:

   /your linked profile/

To restrict the match to strings where the desired pattern is at 64 bytes after the start of the string, it would have to be anchored:

        /^.{,64}your linked profile/

--
--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Phil Stracchino
On 04/17/18 13:53, Viktor Dukhovni wrote:

>
>
>> On Apr 17, 2018, at 1:39 PM, Phil Stracchino <[hidden email]> wrote:
>>
>> In a Perl-compatible regular expression, you want something like this:
>>
>> /.{,64}(your linked profile)/
>
> Which (when used verbatim) is equivalent to:
>
>    /your linked profile/
>
> To restrict the match to strings where the desired pattern is at 64 bytes after the start of the string, it would have to be anchored:
>
> /^.{,64}your linked profile/

Oops.  You're right, Viktor, I omitted the start anchor.



--
  Phil Stracchino
  Babylon Communications
  [hidden email]
  [hidden email]
  Landline: +1.603.293.8485
  Mobile:   +1.603.998.6958
Reply | Threaded
Open this post in threaded view
|

Re: Subject Regular expressión

Emanuel

thanks for your help.

regards.


El 17/04/18 a las 15:01, Phil Stracchino escribió:
On 04/17/18 13:53, Viktor Dukhovni wrote:

On Apr 17, 2018, at 1:39 PM, Phil Stracchino [hidden email] wrote:

In a Perl-compatible regular expression, you want something like this:

/.{,64}(your linked profile)/
Which (when used verbatim) is equivalent to:

   /your linked profile/

To restrict the match to strings where the desired pattern is at 64 bytes after the start of the string, it would have to be anchored:

	/^.{,64}your linked profile/
Oops.  You're right, Viktor, I omitted the start anchor.




--
envialosimple.com
Emanuel Gonzalez
IT / Departamento Emails
[hidden email]
www.envialosimple.com
by donweb
 
Nota de confidencialidad: Este mensaje y archivos adjuntos al mismo son confidenciales, de uso exclusivo para el destinatario del mismo. La divulgación y/o uso del mismo sin autorización por parte de DonWeb.com queda prohibida.
DonWeb.com no se hace responsable del mensaje por la falsificación y/o alteración del mismo.
De no ser Ud el destinatario del mismo y lo ha recibido por error, por favor, notifique al remitente y elimínelo de su sistema.
Confidentiality Note: This message and any attachments (the message) are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited by DonWeb.com.
DonWeb.com shall not be liable  for the message if altered or falsified.
If you are not the intended addressee of this message, please cancel it immediately and inform the sender
Nota de Confidencialidade: Esta mensagem e seus eventuais anexos podem conter dados confidenciais ou privilegiados.
Se você os recebeu por engano ou não é um dos destinatários aos quais ela foi endereçada, por favor destrua-a e a todos os seus eventuais anexos ou copias realizadas, imediatamente.
É proibida a retenção, distribuição, divulgação ou utilização de quaisquer informações aqui contidas.
Por favor, informenos sobre o recebimento indevido desta mensagem, retornando-a para o autor.