procmail
[Top] [All Lists]

Re: Simple (for you) regexp question

1998-11-16 12:17:57
Kimmo Jaskari <kimmo(_at_)alcom(_dot_)aland(_dot_)fi> writes:
On Mon, 16 Nov 1998, era eriksson wrote:

 > Ok, I need to match a line that can basically start with anything
 > from one word to 6, but always ends the same way. Thus far I've been
 > using .* even though that for some reason is not the way to do it (yes,
 > when it comes to procmail recipes I'm of the steal, cut and paste school)

You mean like this?

    WORD="[a-z']+\\>+"
    :0:
    * $ ^$WORD($WORD($WORD($WORD($WORD($WORD)?)?)?)?)?\>+same thing as alway
s
    action

This is untested. (For text in a Nordic language, you should probably
add some characters with nice diacritics to the WORD definition, and
perhaps even take out the apostrophe.)

Thanks; perhaps even too specific since I just used the 1-6 to illustrate
that it could be any text at all basically, but that the line always 
ended the same way. I just wondered how are you going to match a line
that can start with anything but end with something specific without
resorting to .*

Simple: don't use '^' to anchor the regexp to the begining of the line,
so that it [the regexp] will match starting somewhere in the middle of
line:

        :0
        * ()\<same thing as always$
        ...

Note that the above regexp would match the line

same thing as always

As \< will match the newline that ended the previous line.


Philip Guenther

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