Index: src/wp-includes/class-wp-query.php
===================================================================
--- src/wp-includes/class-wp-query.php	(revision 38831)
+++ src/wp-includes/class-wp-query.php	(working copy)
@@ -722,8 +722,7 @@
 	 *     @type string       $s                       Search keyword(s). Prepending a term with a hyphen will
 	 *                                                 exclude posts matching that term. Eg, 'pillow -sofa' will
 	 *                                                 return posts containing 'pillow' but not 'sofa'. This feature
-	 *                                                 can be disabled using the
-	 *                                                 'wp_query_use_hyphen_for_exclusion' filter.
+	 *                                                 can be altered with the 'wp_query_search_exclusion_prefix' filter.
 	 *     @type int          $second                  Second of the minute. Default empty. Accepts numbers 0-60.
 	 *     @type bool         $sentence                Whether to search by phrase. Default false.
 	 *     @type bool         $suppress_filters        Whether to suppress filters. Default false.
@@ -1322,18 +1321,19 @@
 		$q['search_orderby_title'] = array();
 
 		/**
-		 * Filters whether search terms preceded by hyphens should excluded from results.
+		 * Filters the prefix denoting that a search term should be excluded from results.
 		 *
 		 * @since 4.7.0
 		 *
-		 * @param bool Whether the query should exclude terms preceded with a hyphen.
+		 * @param string $exclusion_prefix The prefix. Default hyphen. Returning
+		 *                                 an empty value disables exclusions.
 		 */
-		$hyphen_exclusion = apply_filters( 'wp_query_use_hyphen_for_exclusion', true );
+		$exclusion_prefix = apply_filters( 'wp_query_search_exclusion_prefix', '-' );
 
 		foreach ( $q['search_terms'] as $term ) {
-			// Terms prefixed with '-' should be excluded.
-			$include = '-' !== substr( $term, 0, 1 );
-			if ( $include || ! $hyphen_exclusion ) {
+			// If there is an $exclusion_prefix, terms prefixed with it should be excluded.
+			$include = ( ! $exclusion_prefix || ( substr( $term, 0, 1 ) !== $exclusion_prefix ) );
+			if ( $include ) {
 				$like_op  = 'LIKE';
 				$andor_op = 'OR';
 			} else {
Index: tests/phpunit/tests/query/search.php
===================================================================
--- tests/phpunit/tests/query/search.php	(revision 38831)
+++ tests/phpunit/tests/query/search.php	(working copy)
@@ -62,7 +62,7 @@
 	/**
 	 * @ticket 38099
 	 */
-	function test_filter_wp_query_use_hyphen_for_exclusion() {
+	function test_disable_search_exclusion_prefix() {
 		$title = '-HYPHENATION_TEST';
 
 		// Create a post with a title which starts with a hyphen
@@ -74,14 +74,40 @@
 		$this->assertEquals( array(), $this->get_search_results( $title ) );
 
 		// After we disable the feature using the filter, we should get the result
-		add_filter( 'wp_query_use_hyphen_for_exclusion', '__return_false' );
+		add_filter( 'wp_query_search_exclusion_prefix', '__return_false' );
 		$result = $this->get_search_results( $title );
 		$post = array_pop( $result );
 		$this->assertEquals( $post->ID, $post_id );
-		remove_filter( 'wp_query_use_hyphen_for_exclusion', '__return_false' );
+		remove_filter( 'wp_query_search_exclusion_prefix', '__return_false' );
 	}
 
 	/**
+	 * @ticket 38099
+	 */
+	function test_change_search_exclusion_prefix() {
+		$title = '#OCTOTHORPE_TEST';
+
+		// Create a post with a title that starts with a non-hyphen prefix.
+		$post_id = self::factory()->post->create( array(
+			'post_content' => $title, 'post_type' => $this->post_type
+		) );
+
+		// By default, we should get the result.
+		$result = $this->get_search_results( $title );
+		$post = array_pop( $result );
+		$this->assertEquals( $post->ID, $post_id );
+
+		// After we change the prefix, the result should be excluded.
+		add_filter( 'wp_query_search_exclusion_prefix', array( $this, 'filter_search_exclusion_prefix_octothorpe' ) );
+		$this->assertEquals( array(), $this->get_search_results( $title ) );
+		remove_filter( 'wp_query_search_exclusion_prefix', array( $this, 'filter_search_exclusion_prefix_octothorpe' ) );
+	}
+
+	function filter_search_exclusion_prefix_octothorpe() {
+		return '#';
+	}
+
+	/**
 	 * @ticket 33988
 	 */
 	public function test_s_should_exclude_term_prefixed_with_dash() {
