Last active
August 29, 2015 13:59
-
-
Save Elsensee/10593380 to your computer and use it in GitHub Desktop.
ticket/10423 function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Cleans a search string by removing single wildcards from it and replacing multiple spaces with a single one. | |
* | |
* @param string $search_string The full search string which should be cleaned. | |
* | |
* @return string The cleaned search string without any wildcards and multiple spaces. | |
*/ | |
function phpbb_clean_search_string($search_string) | |
{ | |
// This regular expressions matches every single wildcard. | |
// That means one after a whitespace or the beginning of the string or one before a whitespace or the end of the string. | |
$search_string = preg_replace('#(?<=^|\s)\*(?=\s|$)#', '', $search_string); | |
$search_string = trim($search_string); | |
$search_string = preg_replace('#\s+#u', ' ', $search_string); | |
return $search_string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment