procmail
[Top] [All Lists]

Re: matching "search-peak"

1996-10-24 11:39:23
    > I want to match either search-peak or search_peak in the Subject
    > 
    > I was going to use
    > 
    > * ^Subject: search[_|-]peak
    > 
    > but you happened to mention that "-" has special meaning there.
    > 
    > Can you explain why, or point me to TM.

Use

    * ^Subject: *search[-_]peak

The "|" alternation does not work inside of square brackets.  To use
that syntax, you could do:

    * ^Subject: *search(-|_)peak

The difference is that "[ab]" matches the literal characters 'a' and
'b', while "(a|b)" matches the pattern "a" or the pattern "b".  Both "a"
and "b" can be arbitrarily complex regexp patterns themselves, or simple
strings (the trivial case of a pattern).

The syntax "[a-z]" is called a "character class", and the string "a-z"
is a range of characters from "a" to "z".

You can specify the "-" character in a character class by making it the
first character in the class: ie: "[-_.a-zA-Z0-9]", which matches an
alphanumeric character, or "-", "_", or ".".

To match anything but the given class, prefix the class with "^"; eg:
[^-_.a-zA-Z0-9] matches anything but an alphanumeric, "-", "_", or ".".

All of this is described in the regex/egrep/sed/ed man pages.

___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks

<Prev in Thread] Current Thread [Next in Thread>
  • Re: matching "search-peak", Alan K. Stebbens <=