Switch -Regex in Powershell

Question!
$source |% {
switch -regex ($_){
'\<'+$primaryKey+'\>(.+)\</'+$primaryKey+'\>' { 
$primaryKeyValue = $matches[1]; continue; }

}

I want to use dynamic key value with switch-regex, is that possible?



Answers

You can use a string which automatically expands variables:

switch -regex (...) {
    "
By : Joey


This video can help you solving your question :)
By: admin