This code works perfectly fine for my purposes.
However, it's a little ugly because there is obvious duplication.
I've been playing with this and regular expressions for about an hour and could not seem to merge the check into a single expression.
But I'm quite certain it must be possible to have optional matches...
Any tips, even if it is simply a suggestion of what keywords I should be Googling?
Func GetNthValueFromStatubar($n)
; Get status text as string.
$Status = StatusbarGetText($MainWindowTitle)
; Find value based on N.
If $n = 1 Then
$Result = StringRegExp( $Status, "[A-Za-z: ]+\$([A-Z0-9]+)", 1 )
ElseIf $n = 2 Then
$Result = StringRegExp( $Status, "[A-Za-z: ]+\$([A-Z0-9]+)[\s]*[A-Za-z: ]+\$([A-Z0-9]+)", 1 )
ElseIf $n = 3 Then
$Result = StringRegExp( $Status, "[A-Za-z: ]+\$([A-Z0-9]+)[\s]*[A-Za-z: ]+\$([A-Z0-9]+)[\s]*[A-Za-z: ]+\$([A-Z0-9]+)", 1 )
EndIf
Return $Result[$n - 1]
EndFunc