Well I'm sure there are times when -1 is appropriate but in this case we're simply looking for a flag to show that we did not find the value so anything aside from 0 would indicate it was not found.

Comments for your 2nd solution similar to first with regards to using var names with meaning if used in larger script, though not the case here.

Good idea for splitting based upon Reg Type

Here is a method to remove the space from your output check.

$J = Trim(Join($S," "))