Reputation: 15
I'm using powershell and regex. I'm scraping a web page result to a variable, but I can't seem to extract a generated url from that variable.
this is the content (the actual url varies):
"https://api16-something-c-text.sitename.com/aweme/v2/going/?video_id=v12044gd0666c8ohtdbc77u5ov2cqqd0&
$reg = "([^&]*)&;$"
always returns false.
I've been trying -match
and Select-String
with regex but I'm in need of guidance.
Upvotes: 0
Views: 442
Reputation: 821
It really depends on what format the content is in.
(?<=\")
looks behind """ for (.*?)
which any numbers of non-newline characters and then looks ahead for (?=\&)
which is "&".
Here's a fair start:
$pattern = "(?<=\")(.*?)(?=\&)"
$someText = ""https://api16-something-c-text.sitename.com/aweme/v2/going/?video_id=v12044gd0666c8ohtdbc77u5ov2cqqd0&"
$newText = [regex]::match($someText, $pattern)
$newText.Value
Returns:
https://api16-something-c-text.sitename.com/aweme/v2/going/?video_id=v12044gd0666c8ohtdbc77u5ov2cqqd0
Upvotes: 0