Bug #68810 [NEW]: i guess i have found some problem with regular expressions
| From: | andrecamargotii at gmail dot com | Date: | Mon, 12 Jan 2015 12:30:42 +0000 |
| Subject: | Bug #68810 [NEW]: i guess i have found some problem with regular expressions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-189899@lists.php.net to get a copy of this message | ||
From: andrecamargotii at gmail dot com
Operating system: Arch linux
PHP version: 5.6.4
Package: Scripting Engine problem
Bug Type: Bug
Bug description:i guess i have found some problem with regular expressions
Description:
------------
sorry for the english
i wrote this script
$lines = file( $this->file, FILE_IGNORE_NEW_LINES |
FILE_SKIP_EMPTY_LINES );
foreach ( $lines as $line ) {
$numline = $numline+1;
if( preg_match( '/new\s?[a-z0-9]+\s?/i', $line)) { echo "ok
$numline";}
}
}
and $this-file refers to an file where i wrote this:
new CR_a123)
the script print in the screen ok followed by number of the line
(wrong)
if i change the script to this
$lines = file( $this->file, FILE_IGNORE_NEW_LINES |
FILE_SKIP_EMPTY_LINES );
foreach ( $lines as $line ) {
$numline = $numline+1;
if( preg_match( '/new\s?[a-z0-9]+\s?\)/i', $line)) { echo "ok
$numline";}
}
}
the script don't print anything (right)
thanks for the help
the first script was worng because the expression have an underscore,
and in script i especified that can be only numbers and letters. the
second script is correct because the script cannot output ok.
i change the second script to:
$lines = file( $this->file, FILE_IGNORE_NEW_LINES |
FILE_SKIP_EMPTY_LINES );
foreach ( $lines as $line ) {
$numline = $numline+1;
if( preg_match( '/new\s?[a-z0-9_]+\s?\)/i', $line)) { echo "ok
$numline";}
}
}
the third script prints ok (right)
now i have put underscore in the regular expression, so now the script
can print ok.
--
Edit bug report at https://bugs.php.net/bug.php?id=68810&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68810&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68810&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68810&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68810&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68810&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68810&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68810&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68810&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68810&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68810&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68810&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68810&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68810&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68810&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68810&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68810&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68810&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68810&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68810&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68810&r=mysqlcfg