# No search result if filtered by unicode username

**URL:** <https://meta.discourse.org/t/no-search-result-if-filtered-by-unicode-username/243349>\
**Category:** Bug\
**Created:** [October 31, 2022, 5:16am UTC](https://meta.discourse.org/t/no-search-result-if-filtered-by-unicode-username/243349 "2022-10-31T05:16:22Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![topological](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@topological](https://meta.discourse.org/u/topological)\
**Post date:** [October 31, 2022, 7:34am UTC](https://meta.discourse.org/t/no-search-result-if-filtered-by-unicode-username/243349/3 "2022-10-31T07:34:56Z")

</div>

I use a plugin to add the advanced\_filter by following code, and it satisfies my needs.

```ruby
if SiteSetting.unicode_usernames?
    regexp = Regexp.new("(?i-mx:^\\@([a-zA-Z0-9_\\-.#{SiteSetting.allowed_unicode_username_characters}]+)$)")
    Search.advanced_filter(regexp) do |posts, match|
      username = match.downcase
  
      user_id = User.where(staged: false).where(username_lower: username).pluck_first(:id)
  
      if !user_id && username == "me"
        user_id = @guardian.user&.id
      end
  
      if user_id
        posts.where("posts.user_id = #{user_id}")
      else
        posts.where("1 = 0")
      end
    end
  end

```

But I don’t know how to modify the core properly, especially when `allowed_unicode_username_characters` is a variable. Maybe a simple but probably wrong solution is to change `advanced_filter(/^\@([a-zA-Z0-9_\-.]+)$/i)` to `advanced_filter(/^\@(.+)$/i)`, just like you did in `advanced_filter(/^user:(.+)$/i)`.

---

_[View the full topic](https://meta.discourse.org/t/no-search-result-if-filtered-by-unicode-username/243349)._
