I have been looking for a way to parse URL from a string. My current goal is to parse
from a string like
abcxyz https://example.com/foo.png gibberfish text.
Anyone got a solution or a package that can help me to do the job? Thanks in advance.
I have been looking for a way to parse URL from a string. My current goal is to parse
from a string like
abcxyz https://example.com/foo.png gibberfish text.
Anyone got a solution or a package that can help me to do the job? Thanks in advance.
I recommend this solution. It turns all words into an array and picks out the ones starting with https://
text.split(" ").filter(i => i.startsWith("https://")).toString();
text = "abcxyz https://example.com/foo.png gibberfish text."
console.log(text.split(" ")[1])
.split()
splits the string at spaces into an array of words.
You can refer: https://www.w3schools.com/jsref/jsref_split.asp