How would you go about counting the number of strings within a string using Powershell?
For example:
$a = "blah test <= goes here / blah test <= goes here / blah blah"
I want to count how many times <= goes here /
appears in the above.
I had a string with a bunch of pipes in it. I wanted to know how many there were, so I used this to get it. Just another way :)
$ExampleVar = "one|two|three|four|fivefive|six|seven";
$Occurrences = $ExampleVar.Split("|").GetUpperBound(0);
Write-Output "I've found $Occurrences pipe(s) in your string, sir!";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With