var link = '<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=https://www.google.com/">'; link.match(/^ ">$/ig); How do I get https://www.google.com/ using a regular expression?
var link = '<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=https://www.google.com/">'; link.match(/^ ">$/ig); How do I get https://www.google.com/ using a regular expression?
It can be very simple:
var link = '<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=https://www.google.com/">'; link.match(/URL=(.+)">$/i); Result:
array( 0 => URL=https://www.google.com/"> 1 => https://www.google.com/ ) Here is a good cheat sheet: https://www.exlab.net/files/tools/sheets/regexp/regexp.png
Начало строки: '^' Конец строки: '$' In this case, no check at the beginning of the line is needed.
preg_match('/URL=(.+)">$/i', $input_line, $output_array); ;? - Wiktor Stribiżew FebruaryYou need a preview here:
link.match(/(?<=URL=).+(?=")/)[0] You can still through split() :
link.split(/URL=|"/)[4] And you can also use replace() :
link.replace(/.+URL=|">/g,"") Source: https://ru.stackoverflow.com/questions/942568/
All Articles
https://www.google.com/related to checking the beginning and end? - Grundy