mudasobwa

mudasobwa

Creator of Cure

Regex punctuation matchers

AFAIU, Elixir delegates regular expression evaluation to Erlang.

Erlang claims to support Unicode general category matchers.

is declared in Unicode spec as LEFT DOUBLE QUOTATION MARK under General punctuation. Both Ruby and Perl do recognize this symbol as opening punctuation:

[0x201C].pack('U*').match /\p{Pi}/
#⇒ #<MatchData "“">

Both Elixir and Erlang, unfortunately, do not:

Regex.scan(~r/[\p{Pi}\p{Pf}\p{Ps}\p{Pe}]/, "'\"“”‘’«»")
#⇒ [[<<171>>], [<<187>>]] # these are « and »

What am I missing and/or what should I tune to make the regex engine to work properly?

Marked As Solved

NobbZ

NobbZ

You forgot to enable unicode mode:

iex(1)> Regex.scan(~r/[\p{Pi}\p{Pf}\p{Ps}\p{Pe}]/, "'\"“”‘’«»")
[[<<171>>], [<<187>>]]
iex(2)> Regex.scan(~r/[\p{Pi}\p{Pf}\p{Ps}\p{Pe}]/u, "'\"“”‘’«»")
[["“"], ["”"], ["‘"], ["’"], ["«"], ["»"]]

Also Liked

mudasobwa

mudasobwa

Creator of Cure

Fair enough.

This is a matter of personal preference and I cordially avoid wasting core team time with such requests :slight_smile:

mudasobwa

mudasobwa

Creator of Cure

C’mon :slight_smile:

sigil_ฤ.

mudasobwa

mudasobwa

Creator of Cure

Thanks! I wonder how come it’s disabled by default.

Last Post!

mudasobwa

mudasobwa

Creator of Cure

I live in 2022 :slight_smile:

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement