Regex, new line character

Hello everyone!

I have a problem with regex.

Why doesn’t it work?
Regex.run ~r/<svg>(.+?)<\/svg>/, "<svg> some\n data </svg>"
nil

I need to get ["<svg> some data </svg>", " some\n data "].

Thank you for your help!

1 Like

You have to add the ‘s’ modifier, Regex.run ~r/(.+?)</svg>/s, " some\n data "

1 Like

Thank you! :slight_smile:

1 Like
iex(10)> Regex.run(~r/<svg>(.+?)<\/svg>/s, "<svg> some\n data </svg>")
["<svg> some\n data </svg>", " some\n data "]
1 Like