|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-11-15 19:26 UTC] ramsey@php.net
Description:
------------
Everytime I try to use the FL_REGEXP filter, it returns NULL. This is when compiled against the system's pcre.h.
Reproduce code:
---------------
<?php
var_dump(filter_data('foo', FL_REGEXP, array('regexp' => '/^\w+$/')));
?>
Expected result:
----------------
string(3) "foo"
Actual result:
--------------
NULL
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 09:00:01 2025 UTC |
I'm reopening this bug because, now, FILTER_VALIDATE_REGEXP always appear to return FALSE (even if removing the forward slash delimiters). EXAMPLE CODE: <?php // $_GET['name'] = 'John Doe' $name = 'John Doe'; $expression = '/^[[:alpha:]\ \-\']+$/'; $options = array('regexp' => $expression); var_dump(filter_input(INPUT_GET, 'name', FILTER_VALIDATE_REGEXP, $options)); var_dump(preg_match($expression, $_GET['name'])); var_dump(filter_var($name, FILTER_VALIDATE_REGEXP, $options)); var_dump(preg_match($expression, $name)); ?> EXPECTED RESULT: string(8) "John Doe" int(1) string(8) "John Doe" int(1) ACTUAL RESULT: bool(false) int(1) bool(false) int(1)I'm closing this bug because my last comment was bogus. I should've been passing the options arguments like this: array('options' => array('regexp' => $expression)) So, the comment wasn't even related to the earlier problems described here. The API simply changed, and I didn't notice it.