[drupal-support] Regex to hide/show a block

Travis Spencer travislspencer at gmail.com
Sun Aug 28 00:28:42 UTC 2005


Hey All,

In the `Pages' textbox under `admin/block/configure/menu/25' (i.e., my
block associated with some menu), I have the following:

<^node/[59]($|/.*)>
<^node/1[0-4]($|/.*)>

I've selected the `Show on only the listed pages.' option, so I would
expect the block to be displayed on pages with these URLs:

node/5
node/10
node/9
node/9/edit
node/5/edit
node/10/edit
node/11/edit
node/12/edit
node/112
node/11
node/12
node/13
node/14

However, it only displays on pages *without* `edit' in the URL.  Also,
it *does* show up on pages such as `node/10/' (note the trailing
slash).

This is very confusing.  To test things more easily and since drupal
and PHP use PCRE regular expressions, grep's `-P' option (which
searches using a PCRE library) should produce the same results as
drupal (but without all the clicking).  However, it doesn't; it
matches just as I would expect it to:

mj% cat patterns | while read pattern ; do
pipe while> echo "$pattern: " ; grep -P "$pattern" < input
pipe while> done
^node/[59]($|/.*):
node/5
node/9
node/9/edit
node/5/edit
^node/1[0-4]($|/.*):
node/10
node/10/edit
node/11/edit
node/12/edit
node/11
node/12
node/13
node/14
mj% cat patterns
^node/[59]($|/.*)
^node/1[0-4]($|/.*)
mj% cat input
node/5
node/10
node/9
node/9/edit
node/5/edit
node/10/edit
node/11/edit
node/12/edit
node/112
node/11
node/12
node/13
node/14

Does anyone see where I'm going wrong?  TIA.

-- 

Regards,

Travis Spencer



More information about the drupal-support mailing list