Powershell regex to replace and return only the values in the string

  Kiến thức lập trình

I have a string

$vardata = " -var subscription_id=SUBSCRIPTION_ID -var tenant_id=TENANT_ID -var kt_subscription_id=KT_SUBSCRIPTION_ID -var ecr_subscription_id=ECR_SUBSCRIPTION_ID "

I want to replace everything from “-var to =” and get only the value assigments like

SUBSCRIPTION_ID
TENANT_ID
KT_SUBSCRIPTION_ID
ECR_SUBSCRIPTION_ID

etc

I tried

$kv = [regex]::Matches($vardata-replace '-var*[^=]').Value

doesnt seem to wrk

LEAVE A COMMENT