# Regular expression (non-English)

**URL:** https://meta.discourse.org/t/regular-expression-non-english/63471
**Category:** Development
**Created:** [May 27, 2017, 9:24am UTC](https://meta.discourse.org/t/regular-expression-non-english/63471 "2017-05-27T09:24:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [May 27, 2017, 9:24am UTC](https://meta.discourse.org/t/regular-expression-non-english/63471/1 "2017-05-27T09:24:57Z")

</div>

Continuation: [Tag search in tags dropdown box does not work for non-English characters](https://meta.discourse.org/t/tag-search-in-tags-dropdown-box-does-not-work-for-non-english-characters/53731)

file: discourse\_tagging.rb

```
- term.gsub!(/[^a-z0-9\.\-\_]*/, '')
+ term.gsub!(/[^a-z0-9а-я\.\-\_]*/, '')

```

All checks have failed

```
- term.gsub!(/[^a-z0-9\.\-\_]*/, '')
+ term.gsub!(/[^a-z0-9\p{Cyrillic}\.\-\_]*/, '')

```

[https://github.com/discourse/discourse/pull/4886](https://github.com/discourse/discourse/pull/4886)  
All checks have passed

- The construction: `а-я` is private (for the Russian language).
- The construction: `p{Cyrillic}` (Describes many cases)

All options work on localhost

If the construction: p{Cyrillic} - Is true (and it works fine on my site), then the same will be done in the file: search.rb in the search for tags.

`448 advanced_filter(/tags?:([a-zA-Z0-9,\-_]+)/) do |posts, match|`

What do you think about it?

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [May 27, 2017, 1:12pm UTC](https://meta.discourse.org/t/regular-expression-non-english/63471/2 "2017-05-27T13:12:15Z")

</div>

Is it possible to do this in a way that also contain other alphabets like Persian and Arabic?

---

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [May 27, 2017, 2:25pm UTC](https://meta.discourse.org/t/regular-expression-non-english/63471/3 "2017-05-27T14:25:59Z")

</div>

I think if you change the code: `p{Cyrillic}`  
It is necessary to find what is suitable, then yes.

> <https://stackoverflow.com/questions/25242423/regular-expression-in-arabic-language>

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [May 27, 2017, 9:39pm UTC](https://meta.discourse.org/t/regular-expression-non-english/63471/4 "2017-05-27T21:39:58Z")

</div>

I think `\p{Alnum}` would be the right choice.

> **[Idiosyncratic Ruby: Regex with Class](https://idiosyncratic-ruby.com/30-regex-with-class.html)**
>
> Documenting All Ruby Specialities.

---

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [May 28, 2017, 4:57am UTC](https://meta.discourse.org/t/regular-expression-non-english/63471/5 "2017-05-28T04:57:23Z")

</div>

> [@gerhard](#):
>
> I think \p{Alnum} would be the right choice.

I checked: localhost - works (As well as: а-я, p{Cyrillic} …)  
But the test showed:

`term.gsub!(/[^a-z0-9\p{Alnum}\.\-\_]*/, '')`  
**All checks have failed**

Strangely (Although it already includes both letters and numbers)  
delete  
`- a-z0-9`

Can you make a correction yourself?  
This bug is initially there, and working with tags is an important part.

**P.S.** `term.gsub!(/[^\p{Alnum}\.\-\_]*/, '')` - working (All checks have passed)  
file: search.rb - does not need correction
