から部分を引っ張る私はこのような$の一時中のURIのリストからちょうどこのPowerShellの - URI
hrbkr.com
smqzc.com
znynf.com
を引くしようとしている -
anything.anything.hrbkr.com
anything.anything.smqzc.com
anything.anything.znynf.com
この正規表現がで一致しているようですregex101に少なくとも -
(<domainname>(?<ip>^[A-Fa-f\d.:]+$)|(?<nodots>^[^.]+$)|(?<fqdomain>(?:(?:[^.]+.)?(?<tld>(?:[^.\s]{2})(?:(?:.[^\.\s][^\.\s])|(?:[^.\s]+)))))$)*?'
しかし、これは私に何も結果が得られていないようです、私はそれが全体のラインに一致するように取得することができるが、私はちょうどトンをしたいです行が一致すれば彼は '部分文字列'ではなく真です。
$temp = ‘c:\Users\money\Downloads\phishinglist.txt’
$regex = '(<domainname>(?<ip>^[A-Fa-f\d.:]+$)|(?<nodots>^[^.]+$)|(? <fqdomain>(?:(?:[^.]+.)?(?<tld>(?:[^.\s]{2})(?:(?:.[^\.\s][^\.\s])|(?:[^.\s]+)))))$)*?'
$temp | select-string -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } | Sort-Object -Unique > $list
$list
ありがとうございます!
System.Uriクラスはhttp:// stac kobeflow.com/questions/14363214/get-domain-from-url-in-powershell –