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. · GitHub, 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
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
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’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
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Other popular topics
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
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
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
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
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
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










