Match/act per line?

awry - May 12, 2009 - 01:55
Project:Flexifilter
Version:6.x-1.0
Component:User interface - Admin pages
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

How do I get flexifilter to match and act on a per-line basis?

For example, I want to create a new input type for filtering mail that arrives via mail2web. I want to remove all of the reply text from everyone's annoyingly top-posted emails. So I need to create a filter that removes each line beginning with '>' from the input.

I believe the chunk grabber component might be the way to do this, combined with a regex replace with an empty replacement string? But I can't figure out what delimiters to use to match a line. The PCRE '^' and '$' don't apparently do it.

For some reason I'm having a heck of a time figuring this out, even though it seems like it should be pretty simple.

Thanks.

#1

kiamlaluno - July 22, 2009 - 21:33

'^' and '$' must be used with the multiline modifier, to match the beginning and the end of a line of text; differently, they will match the beginning and the end of the full string.

If the module doesn't allow you to set the modifiers to use, then it's not possible to match the beginning, and the end of each text line.

#2

kiamlaluno - July 22, 2009 - 22:10

As alternative, if you cannot specify the modifiers at the end of the regular expression (as it is usually done in PHP), you can specify them at the beginning of the regular expression; in your case, it's enough you add "(?m)" at the beginning of the regular expression you want to use.
For more details, see Internal option setting.

 
 

Drupal is a registered trademark of Dries Buytaert.