1

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.