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
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, "'\"“”‘’«»")
[["“"], ["”"], ["‘"], ["’"], ["«"], ["»"]]
3
Also Liked
mudasobwa
Creator of Cure
Fair enough.
This is a matter of personal preference and I cordially avoid wasting core team time with such requests ![]()
2
mudasobwa
Creator of Cure
Last Post!
mudasobwa
Creator of Cure
Popular in Questions
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
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
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
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
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
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
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
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
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
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
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
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









