Skip to content

Commit 4cdb4fb

Browse files
committed
Fix #719
1 parent a2f4eca commit 4cdb4fb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,9 @@ protected function compileWhereBasic($where)
930930
if ($operator == 'like')
931931
{
932932
$operator = '=';
933-
$regex = str_replace('%', '', $value);
933+
934+
// Convert to regular expression.
935+
$regex = preg_replace('#(^|[^\\\])%#', '$1.*', preg_quote($value));
934936

935937
// Convert like to regular expression.
936938
if ( ! starts_with($value, '%')) $regex = '^' . $regex;

0 commit comments

Comments
 (0)