How do i extract the first instance of the below pattern from string.
$a="CIC-284 Updated code to reflect changes from Defect 46"
$a -match "CIC-*"
True
Expected result : CIC-284 from the string using powershell.
Your regular expression (CIC-*) matches the character sequence "CIC" followed by any number of hyphens. The asterisk is a quantifier with the meaning "zero or more times the preceding expression".
To match the character sequence "CIC-" followed by any number of digits change your expression to CIC-\d*. \d is an escape sequence that matches digits. Alternatively you can use [0-9] instead of \d.