[pmwiki-devel] Group.Name pattern

Patrick R. Michaud pmichaud at pobox.com
Fri Dec 8 12:13:09 CST 2006

On Fri, Dec 08, 2006 at 05:43:49PM +0000, Hans wrote:
> I am looking for a good way to match a target pagename against
> patterns in an array.
> [...]

Would the (built-in) MatchPageNames() function work for you?
It understands arrays of patterns, where the patterns can be
either regular expressions or wildcards.

The format of MatchPageNames() is:

    $newlist = MatchPageNames($oldlist, $patterns)

   $oldlist is a pagename or array of pagenames, and
   $patterns is an array of patterns to be matched
      if a pattern starts with a slash, 
         the pagename must match the pattern
      else if the pattern starts with an exclamation point, 
         the pagename must not match the pattern
      else the pagename must match the wildcard pattern


    # all pages in the Category group, wildcard
    $list = MatchPageNames($list, 'Category.*')

    # another way of saying the above, regex
    $list = MatchPageNames($list, '/^Category\\./')

    # all pages except "junk" pages:
    $list = MatchPageNames($list, array(

    # same as above using wildcards
    $list = MatchPageNames($list, array(

    # all pages in Category and Main except junk pages
    # (mixed wildcards and regexes)
    $list = MatchPageNames($list, array(


More information about the pmwiki-devel mailing list