Extracting specific data from a string with regex and Powershell

The quick and dirty:

$found = $string -match '.*spid="(\d+)".*'
if ($found) {
    $spid = $matches[1]
}

where $string is your above mentioned string. This would match any string that has spid=”somenumberhere”, and make the number into a matched group, which you can extract using $matches[1].

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)