Count number of strings within a string?

powershell, string

Solution

another way (similar to @mjolinor way) in one line:

([regex]::Matches($a, "<= goes here /" )).count

Problem

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.

Original source