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
Comment #1
arhip commentedHi. May I know what version of PHP you're using?
Comment #2
arhip commentedI've tried your regex and didn't get any warning, but didn't work either. So I try to modify your regex into this:
And it works (if I don't misunderstand). The warning might be come from absence of
/msafter the regex. That part is for telling the filter to use$as a line break character, and.matches all characters including line break.Comment #3
rmyoung commentedI am using php 4.3.9. That new regex works, thankyou very much!
Comment #4
rmyoung commentedWhen 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>Comment #5
arhip commentedBy changing
$into\nthe filter work as supposed to be:/(\>\s{0,3}.*\n)+/msThis worked on my system.
Comment #6
arhip commentedOr maybe this is better:
/((^\s*\>\s{0,3}.*(\n|$))+)/mSince this filters out only when > sign is preceeding all characters in a line, so it doesn't match
abc def > ghi jklComment #7
rmyoung commentedThanks 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
> abcare 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.Comment #8
avpadernoI am setting this report as fixed because it got an answer already.
Comment #10
avpaderno