I am trying to make a filter to replace quoted email messages with a simple quotation. Eg. for

r_myoung@yahoo.com.au wrote:
> I have finished the new website and it is live now. Please check it
> out. I would appreciate any comments, positive or negative. You can

I want to replace it with > ...

I am using the following regex supplied by another drupal user:
/(\>\s{0,3}.*\n\>\s{0,3}.*\n)+/ and replacing it with > ...
php is not selected.

When I apply the filter no content is shown at all and the following error message appears: warning: Unknown modifier ' ' in /home/e-smith/files/ibays/test/html/modules/customfilter/customfilter.module on line 931.

Where have I gone wrong?

Comments

arhip’s picture

Hi. May I know what version of PHP you're using?

arhip’s picture

Title: unknown moderator » unknown modifier

I've tried your regex and didn't get any warning, but didn't work either. So I try to modify your regex into this:

/(\>\s{0,3}.*$)+/ms

And it works (if I don't misunderstand). The warning might be come from absence of /ms after the regex. That part is for telling the filter to use $ as a line break character, and . matches all characters including line break.

rmyoung’s picture

I am using php 4.3.9. That new regex works, thankyou very much!

rmyoung’s picture

When I use this regex it filters out all of the text once it finds a quote ie. > line one.

This is fine but when someone adds text following the quote instead of preceding it it is filtered out. How can I change the regex to only remove the lines starting with > and not any lines following the lines with >

arhip’s picture

By changing $ into \n the filter work as supposed to be:

/(\>\s{0,3}.*\n)+/ms

This worked on my system.

arhip’s picture

Or maybe this is better:

/((^\s*\>\s{0,3}.*(\n|$))+)/m

Since this filters out only when > sign is preceeding all characters in a line, so it doesn't match

abc def > ghi jkl

rmyoung’s picture

Thanks arhip,

that last filter works much better. The problem with the following text being filtered out was due to the line break filter being applied. It was being applied with even weight with the quotation filter in posts. Once I made the quotation filter lighter than the line break filter (ie. so it runs first) only the lines with > abc are being filtered out and the lines following it remain.

The line break filter would create lines with <p> and <br/> which would be filtered as they have a > in them.

avpaderno’s picture

Status: Active » Fixed

I am setting this report as fixed because it got an answer already.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Title: unknown modifier » Unknown modifier