Forum Discussion
gongyan
Dec 24, 2021Copper Contributor
Regarding the problem of -match not updating the $Matches variable after matching
这是我代码的一部分 $Matches = 0
$url_0_0_regex = '(?<=a href="\.\./\.\./\.\./).+?(?=">2<)'
#$url_1_context
#sleep -Seconds 50
$result_bool = $url_1_context -match $url_0_0_regex
...
- Dec 24, 2021$Matches hold the success matches and its a hashtable
maybe the 0 you are getting is the first key of the hashtable
try $Matches.Values
can you provide a string of matching?
farismalaeb
Dec 24, 2021Iron Contributor
$Matches hold the success matches and its a hashtable
maybe the 0 you are getting is the first key of the hashtable
try $Matches.Values
can you provide a string of matching?
maybe the 0 you are getting is the first key of the hashtable
try $Matches.Values
can you provide a string of matching?
gongyan
Dec 25, 2021Copper Contributor
Hello, thank you for your reply!
$url_1_context is the html source code of a web page. I use the regular expression $url_0_0_regex to match, and output the value of $Matches by judging the result of -match if($result_bool ), but obviously, the value of $Matches is another- The value after the match operation; it matches another regular expression, but does not match the regular expression represented by $url_0_0_regex.
In addition, it should be noted that the code here is in a function (get_content), and this function (get_content) is called by another function (get_url_name), before calling this function (get_content), once- match operation.