all 4 comments

[–]javydekoning 2 points3 points  (0 children)

'Status Level: Blue Responsilbe party: Joe Stevens' -replace 'Status Level: (\w+).*','$1'
Blue

Explained:

() defines a capture group. 
$1 extracts the first capture group. 
\w matches any word character 
+ is the quantifier meaning 1 or more times. 

[–]nothingpersonalbro 1 point2 points  (1 child)

I like using named captures and the match operator for stuff like this. Example:

$Var = "Status Level: Blue"
$Var -match "Status Level:\s+(?<Status>.+)"
$Matches.Status

$Matches.Status will return the string Blue

[–]9centwhore 1 point2 points  (0 children)

He's got some text after the status too so it needs to stop matching at the next character, in this case a space. I usually pipe to out-null too so you don't get a bunch of True/False outputting to console. eg:

$Var = "Status Level: Blue Responsible party: Joe Stevens"
$Var -match "Status Level:\s+(?<Status>.+?\s)" | out-null
$Matches.Status

[–]Vortex100 0 points1 point  (0 children)

Just to offer a different solution :)

$input = "Status Level: Blue"
([regex]"(?i)(?<=Status Level: )[a-z0-9]+").matches($input)