Find string using pattern and return only the matched string
hi all
scratching head 1 , use help.
have file contains sddl dump. trying find each sid in file , write value variable. following regular expression seems provide pattern match.
"s-(.)*\)"
when run following commend returns whole file contents
select-string -path $file -pattern "s-(.)*\)"
want return strings matching pattern , not entire file contents. understand output select-string matchinfo object, can't see properties or methods me extract string matching pattern.
thoughts?
tony
scratching head 1 , use help.
have file contains sddl dump. trying find each sid in file , write value variable. following regular expression seems provide pattern match.
"s-(.)*\)"
when run following commend returns whole file contents
select-string -path $file -pattern "s-(.)*\)"
want return strings matching pattern , not entire file contents. understand output select-string matchinfo object, can't see properties or methods me extract string matching pattern.
thoughts?
tony
i've reached [regex]::matches when i've had this. not easy 1 like...
get-content -path data.txt | %{ [regex]::matches($_, "s-[0-9\-]*") } | %{ $_.value }
Windows Server > Windows PowerShell
Comments
Post a Comment