diff --git a/include/ajax.orgs.php b/include/ajax.orgs.php
index 041678c0b1166374afc8715030029cf838695a1c..202d2d8f095d8739d0b1ebb6ea2bc85c08dcd6d6 100644
--- a/include/ajax.orgs.php
+++ b/include/ajax.orgs.php
@@ -38,7 +38,7 @@ class OrgsAjaxAPI extends AjaxController {
         $orgs->order_by(new SqlCode('__relevance__'), QuerySet::DESC)
             ->distinct('id');
 
-        if (!count($orgs) && substr($q, strlen($q)-1) != '*') {
+        if (!count($orgs) && preg_match('`\w$`u', $q)) {
             // Do wildcard full-text search
             $_REQUEST['q'] = $q."*";
             return $this->search($type);
diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php
index 31457ec4f80497849129f1a5f126ac7d8a4c21fb..9a5822e123797a77313f52cccd9426580dcfbaac 100644
--- a/include/ajax.tickets.php
+++ b/include/ajax.tickets.php
@@ -66,7 +66,7 @@ class TicketsAjaxAPI extends AjaxController {
                 ->limit($limit)
                 ->union($hits);
         }
-        elseif (!count($hits) && $q[strlen($q)-1] != '*') {
+        elseif (!count($hits) && preg_match('`\w$`u', $q)) {
             // Do wild-card fulltext search
             $_REQUEST['q'] = $q.'*';
             return $this->lookup();
diff --git a/include/ajax.users.php b/include/ajax.users.php
index 0dd6da74b3384f14d16800c6c36ca657220cf7d6..03e203000594973768e7dd5c29f9e8d55982841d 100644
--- a/include/ajax.users.php
+++ b/include/ajax.users.php
@@ -55,7 +55,7 @@ class UsersAjaxAPI extends AjaxController {
             $users->order_by(new SqlCode('__relevance__'), QuerySet::DESC)
                 ->distinct('id');
 
-            if (!count($emails) && !count($users) && substr($q, strlen($q)-1) != '*') {
+            if (!count($emails) && !count($users) && preg_match('`\w$`u', $q)) {
                 // Do wildcard full-text search
                 $_REQUEST['q'] = $q."*";
                 return $this->search($type);
diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php
index 6e2defbe79fdb41bf0fa478119cbf8682e91a7bd..a3701e627a0994bd40fce7b3e1c336fba5862a94 100644
--- a/include/staff/tickets.inc.php
+++ b/include/staff/tickets.inc.php
@@ -94,11 +94,12 @@ case 'search':
             }
         }
         elseif ($_REQUEST['query']) {
+            $q = trim($_REQUEST['query']);
             // [Search] click, consider keywords
-            $__tickets = $ost->searcher->find($_REQUEST['query'], $tickets);
-            if (!count($__tickets)) {
+            $__tickets = $ost->searcher->find($q, $tickets);
+            if (!count($__tickets) && preg_match('`\w$`u', $q)) {
                 // Do wildcard search if no hits
-                $__tickets = $ost->searcher->find($_REQUEST['query'].'*', $tickets);
+                $__tickets = $ost->searcher->find($q.'*', $tickets);
             }
             $tickets = $__tickets;
             $has_relevance = true;