Regular expressions are perhaps Powershell's first-class construct.
If we put together a complete list, we can include the role that square brackets and parentheses play in regular expressions.
Example:
$obj.connectionString = $obj.connectionString -replace '(Data Source)=[^;]+', '$1=serverB\SQL2008_R2'
Because of XML support, you can go so far as to include the square brackets used in XPath. (This is a really long bow, though :-)
select-xml $config -xpath "./configuration/connectionStrings/add[@name='LocalSqlServer']"
Andrew Shepherd
source share