|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-05-10 19:02 UTC] gwbv at yahoo dot com
Description:
------------
Hi,
I have a problem with the @ character at the end of a word, with the word delimiter \b:
input: i wrote this exampl@ for you
preg_match('/\bexampl@/','i wrote this exampl@ for you') = 1
preg_match('/\bexampl@\b/','i wrote this exampl@ for you') = 0
the second preg_match should also return 1 !!
Test script:
---------------
<?php
$input='i wrote this exampl@ for you';
echo "input: ".$input."\n";
$patt='/\bexampl@/';
echo "preg_match('".$patt."','".$input."') = ".preg_match($patt, $input)."\n";
$patt='/\bexampl@\b/';
echo "preg_match('".$patt."','".$input."') = ".preg_match($patt, $input)."\n";
?>
Expected result:
----------------
for both preg_match, output should be 1, that is, the pattern should be found in the input string
preg_match('/\bexampl@/','i wrote this exampl@ for you') = 1
preg_match('/\bexampl@\b/','i wrote this exampl@ for you') = 1
Actual result:
--------------
preg_match('/\bexampl@/','i wrote this exampl@ for you') = 1
preg_match('/\bexampl@\b/','i wrote this exampl@ for you') = 0
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 05:00:01 2025 UTC |
This is not a bug. From PCRE library documentation: " \Biss\B which finds occurrences of "iss" in the middle of words. (\B matches only if the current position in the subject is not a word boundary.) " I.e. \b just makes sense surrounding another word. re> /!\b/ data> ! No match data> re> /a\b/ data> abc a 0: a