Question: I have an issue with a little regex code I wrote. The code basically checks my "longString" which contains the string that's being checked and outputs the words in the string that matches the regex.

```
import java.util.regex.*;

public class regexPractice 
{

    public static void main(String[] args) {
        String  longString = " Derek Banas CA ";

        regexChecker(longString, "\\s[A-Za-z]{2,20}\\s");
    }

    public static void regexChecker(String theregex, String stringCheck) {
        //theregex is the regex your searching for

        Pattern Checkregex = Pattern.compile(theregex);

        Matcher regexMatcher = Checkregex.matcher(stringCheck);

        while (regexMatcher.find()) { //kicks out all the matches for you
            if (regexMatcher.group().length() != 0) {
                System.out.println(regexMatcher.group().trim());
                //trim gets rid of all the white space
            }
        }
    }
}

```

When I run the code nothing shows up not even an error message. I rechecked my code and didn't find any errors.

By the way, I'm using android studio.

Answer: 
There are a couple of issues with your code.

1) The function parameters are not specified correctly; it should be:

```
function IterateThroughMachineSubkeys([string]$machine, [Microsoft.Win32.RegistryKey]$subKey)
{
  ...
}

```

2) The function call is incorrect; it should be:

```
IterateThroughMachineSubkeys -machine $machine.ToString() -subKey $subKey

```

Here is the function in full:

```
function IterateThroughMachineSubkeys([string]$machine, [Microsoft.Win32.RegistryKey]$subKey)
{
    foreach($subKeyName in $subKey.GetSubKeyNames())
    {
        Write-Host -Object ([System.String]::Format("Machine: {0} Module: {1} Version: {2}",
                            $machine.ToString(), $subKeyName.ToString(), 
                            $subKey.OpenSubKey([string]$subKeyName).GetValue("Version", "Not found", [Microsoft.Win32.RegistryValueOptions]::None)))
    }
}

$testKey = get-item "HKCU:\Software"
IterateThroughMachineSubkeys -machine . -subKey $testKey

```

Or using PowerShell cmdlets:

```
$key = get-item "hkcu:\Software\Google\Chrome"
$key | get-childitem | foreach-object { 
    write-host "Machine: $machine Module: $($_.PSChildName) Version: " `
    $key.OpenSubKey($_.PSChildName).GetValue("Version", "Not found", [Microsoft.Win32.RegistryValueOptions]::None) 
}

```
Had this problem, just wanted to point out what fixed it for me:

Print out the variable (echo, Write-Host whatever) and pay incredible attention to what it prints out.

In my case, I didn't assign a return value to a regex search inside my function, so it automatically printed out "True" inside my function, and printouts are returned along with your actual return value as far as I can tell in Powershell, so my return value was "True [actual return value]" which was throwing this error.