tcoopman
Is the multiline modifier for regexes on by default?
It looks like the m multiline modifier for regex is on by default?
iex(17)> Regex.match?(~r/^foo$/, "foo\n")
true
iex(18)> Regex.match?(~r/^foo$/m, "foo\n")
true
I would expect the first case to fail because the multiline modifier is disabled? I know I can use \z but that it is still not clear why the first regex matches.
Marked As Solved
NobbZ
The way elixir does it is consistent with how perl does.
2
Also Liked
AlchemistCamp
It’s also worth pointing out that if you actually want to match across lines, you’ll need the “dotall” s modifier:
Regex.match?(~r/^bar$/s, some_multiline_string)
5
NobbZ
It becomes relevant when you have more than a single line. Single line mode wont try to match in subsequent lines, multi line mode does:
iex(1)> Regex.match?(~r/^bar$/, "foo\nbar\n")
false
iex(2)> Regex.match?(~r/^bar$/m, "foo\nbar\n")
true
2
Popular in Questions
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database.
Dep...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Hey,
I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
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
Sometimes I want to check if the input into a function is not a blank string.
My first approach:
defmodule Example do
def do_stuff(s...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Other popular topics
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
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
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New







