Forum Discussion
dkrabo
Feb 07, 2022Copper Contributor
Masking Sentences
what is the best way to get the result of a** d** g** from input of 'abc def ghi'? with the least performance hit. $test = 'abc def ghi' ((($test -split ' ')).substring(0,1) ) -join ' ' not...
Feb 07, 2022
dkrabo
Ok, created a file containing this to test on (d:\temp\x.txt in my case)
abc def ghi
jkl mno pqr
stu vwx yz
If I let this script run on it:
foreach ($line in get-content d:\temp\x.txt) {
(((($line -split ' ')).substring(0,1) ) -join ' ').Replace(' ','** ') | foreach {$_ + '**'}
}This is the output:
a** d** g**
j** m** p**
s** v** y**
- Jonathan_AllenFeb 08, 2022Brass Contributor
@dkrabo the solution from Harm_Veenstra seems pretty optimised, testing on a 10,000 line text file it masks all values in about 2s when part of a pipeline.
- Feb 08, 2022Didn't even test it in that amount of data 🙂
- Jonathan_AllenFeb 08, 2022Brass Contributorwell, as you had answered the question there wasnt much else for me to do ! 🙂