script
Get complete substrings from a string
Hi
I have this html string
"<div class=wp-block-supertrends-figure><div style=overflow: hidden; padding-top:
56.25%; position: relative;><iframe src=https://player.vimeo.com/video/687889699
frameborder=0 allowfullscreen=></iframe></div><div class=title>Video</div><div
class=text>Video description</div></div>"
I need to extract https://player.vimeo.com/video/687889699 from it.
I need a Regex that matches on http as a starting character and get the entire url because there can be more links with different urls so I don’t want to hardcode this particular url and Regex is not my strong suit and I want to do it with Regex instead of using multiple String.split.
Any help would be appreciated.
Thank you.
Marked As Solved
fuelen
iex> Regex.scan(~r/src=(\S+)/, string <> string, capture: :all_but_first)
[
["https://player.vimeo.com/video/687889699"],
["https://player.vimeo.com/video/687889699"]
]
4
Also Liked
mindok
A well-structured HTML parser, for example: GitHub - philss/floki: Floki is a simple HTML parser that enables search for nodes using CSS selectors., may be a more reliable option.
2
stefanluptak
Naive approach:
str = """
<div class=wp-block-supertrends-figure><div style=overflow: hidden; padding-top:
56.25%; position: relative;><iframe src=https://player.vimeo.com/video/687889699
frameborder=0 allowfullscreen=></iframe></div><div class=title>Video</div><div
class=text>Video description</div></div>
"""
Regex.run(~R|https://player.vimeo.com/video/[0-9]+|, str)
# ["https://player.vimeo.com/video/687889699"]
EDIT: Sorry, I just realized, there can be more URL formats. So consider this irrelevant.
1
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
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir
iex(2)...
New
Other popular topics
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
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
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Hey :wave:t3: Elixir community,
I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New







