Matching pattern with dot in PHP

jmarket

New Member
I need to find and replace substring with dot in it. It's important to keep search strict to word boundaries (\b). Here's an example script to reproduce (i need to match "test."):\[code\]<?php# 1.php$string = 'test. lorem ipsum';if(!preg_match('~\btest\.\b~i', $string)) echo 'no match 1' . PHP_EOL;if(!preg_match('~\btest\b\.~i', $string)) echo 'no match 2' . PHP_EOL;\[/code\]And here's output:\[code\]x:\>php 1.phpno match 1x:\>php -vPHP 5.2.8 (cli) (built: Dec 8 2008 19:31:23)Copyright (c) 1997-2008 The PHP Group\[/code\]BTW, I also don't get any match if there're square brackets in search pattern. I do escape them of course, but still no effect.
 
Back
Top