I'm new on Drupal, new on PHP, just learned regular expression yesterday.

Trying to use this filter to replace [k[漢]blah blah blah] to 漢 linked to specific online dictionary with 漢 entry in target="_blank", set blah blah blah as title of that link.
I've been reading, trying both documentation examples and forum's successful issues.
But none of them work except the simple PHP off code like return "test"; for some simple patterns. (that replaces any matches into "test")
but anything other than that, it just gives me nothing, blank page :(
I've been trying to understand this for 2 days and just can't figure it out by myself... Can someone help me get started?

Comments

Hiroaki’s picture

A bit more detail:

I turned off all of the input format filter except Custom filter 1 and PHP Filter, PHP filter is arranged below Custom Filter 1.

As an example of a rule, I added $1 rule with
Pattern: /<\s*hello\s*>/i
PHP: off
Replacement text:

return "test";

In the body of an example node, I write:

The result I get is:

test

Then at this point, I go back to the Custom Filter configuration page and check the PHP On check box.
I reload the node = > shows nothing! Blank page!

Hiroaki’s picture

Problem solved:
There are 2 problems I had to solve.
1st one is that, in PHP off mode $1-99 didn't work nor $(n).
And on both mode, Japanese letter was not considered as 1 letter. I couldn't catch it by (.) in regex.

At least I works now. But I would appreciate a better documentation for this...

yukare’s picture

Status: Active » Fixed

The issue was fixed by user.

avpaderno’s picture

By default, PHP regular expressions don't consider the characters as Unicode; you should use the modifier /u.

Status: Fixed » Closed (fixed)

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