# How to use Unicode characters in regex named groups?

**URL:** <https://discourse.julialang.org/t/how-to-use-unicode-characters-in-regex-named-groups/20178>\
**Category:** General Usage\
**Tags:** strings, regex\
**Created:** [January 28, 2019, 12:42pm UTC](https://discourse.julialang.org/t/how-to-use-unicode-characters-in-regex-named-groups/20178 "2019-01-28T12:42:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![D\_A](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@D\_A](https://discourse.julialang.org/u/D_A)\
**Post date:** [January 28, 2019, 12:42pm UTC](https://discourse.julialang.org/t/how-to-use-unicode-characters-in-regex-named-groups/20178/1 "2019-01-28T12:42:33Z")

</div>

Hello,

_First, I have to say I am a new user of this language and I try to know if it is suited for my needs and style._

I would like to know how I can use Unicode regex named groups, because it seems it results in an error, contrary to Python (my main programming language).  
Is this a desired behavior (I think it is inconsistent with the Unicode abilities of other parts of the language)? Is there a workaround (other regex engines, etc.)? Is there a good way to fix it (translate the names around the engine)?

Here is a minimal working example with associated error:

**modèle = r"(?P\<données\>.\*)"**

_ERROR: LoadError: LoadError: PCRE compilation error: syntax error in subpattern name (missing terminator) at offset 8_  
_Stacktrace:_  
\_ [1] error(::String) at ./error.jl:33\_  
\_ [2] compile(::String, ::UInt32) at ./pcre.jl:103\_  
\_ [3] compile(::Regex) at ./regex.jl:69\_  
\_ [4] Regex(::String, ::UInt32, ::UInt32) at ./regex.jl:40\_  
\_ [5] Regex(::String) at ./regex.jl:65\_  
\_ [6] @r\_str(::LineNumberNode, ::Module, ::Any, ::Vararg{Any,N} where N) at ./regex.jl:103\_  
\_ [7] include at ./boot.jl:317 [inlined]\_  
\_ [8] include\_relative(::Module, ::String) at ./loading.jl:1041\_  
\_ [9] include(::Module, ::String) at ./sysimg.jl:29\_  
\_ [10] exec\_options(::Base.JLOptions) at ./client.jl:229\_  
\_ [11] _start() at ./client.jl:421_

It works like this, but this “workaround” is to avoid obsolutely:

**modèle = r"(?P\<donnees\>.\*)"**

_Process finished with exit code 0_

Thank you.

Sincerely.

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [January 28, 2019, 12:51pm UTC](https://discourse.julialang.org/t/how-to-use-unicode-characters-in-regex-named-groups/20178/2 "2019-01-28T12:51:34Z")

</div>

This sounds like a bug/limitation in the PCRE library to me. Its [documentation](http://www.pcre.org/current/doc/html/pcre2pattern.html) only says that “Names consist of up to 32 alphanumeric characters and underscores”, without specifying whether only ASCII characters are accepted. You could file a bug there if you want this to be fixed.

---

<div class="post-metadata">

**Author:** ![D\_A](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@D\_A](https://discourse.julialang.org/u/D_A)\
**Post date:** [February 11, 2019, 12:00am UTC](https://discourse.julialang.org/t/how-to-use-unicode-characters-in-regex-named-groups/20178/3 "2019-02-11T00:00:37Z")

</div>

Hello.

Shortly after your answer, I sent a message to Philip Hazel, who kindly answered me, and some days ago he made a [commit](https://vcs.pcre.org/pcre2/code/trunk/src/pcre2test.c?r1=1041&r2=1066) to fix that.

Names will match this pattern in UTF mode: \[1\][\_\p{L}\p{Nd}]\*\z

It should work in the next release (10.33), likely in a couple of months, he said.

Sincerely.

* * *

1. \_\p{L}

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [February 12, 2019, 8:26pm UTC](https://discourse.julialang.org/t/how-to-use-unicode-characters-in-regex-named-groups/20178/4 "2019-02-12T20:26:04Z")

</div>

Thats great, thanks! File an issue against Julia once the new PCRE has been released so that we move to it.
