Forum Discussion
Regarding the problem of -match not updating the $Matches variable after matching
- 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?
I hope I understand your explination, but here are my finding.
The regex example you provide are different and surely they wont match.
Which one are you using '(?<=a href="\.\./\.\./\.\./).+?(?=">2<)' or'a href="\.\./\.\./\.\./.+?(?=">2<)'
I checked the result in regex101.com. The a href="\.\.\/\.\.\/\.\.\/.+?(?=">2<) match the following string a href="../../../read.php?tid=4651187&page=2
and the (?<=a href="\.\.\/\.\.\/\.\.\/).+?(?=">2<) match withread.php?tid=4651187&page=2
So which regex are you using and showing the wrong result.
I think you need to review your regex query, it doesn't matter if you are passing the result from one function to another.
Thank you for your answer.
I discovered later that this is caused by the differences in the implementation of regularization in different programming languages. I use notepad++ software to verify whether the regular expressions can match, but some regular expressions cannot match the expected results correctly in PowerShell.
And in the case of PowerShell, using the -match operator to match and the [regex::] class to match, in some cases, it is not possible to get consistent results.