Created
June 16, 2016 18:13
-
-
Save anonymous/6aa7e18ef3bfedbf0f21ff811c9a8600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You should be able to just use -replace without the -match | |
IE. | |
Get-Content "D:\web.config" | ForEach-Object {$_ -replace " <case match=`"AppleWebKit\/\(\?'version'\(\?'major'\\d\)\(\?'minor'\\d\+\)\(\?'letters'\\w\*\)\)\(\.\* \)\?\(\?'type'\[\^\/\\d]\*\)\/\.\*\( \|\$\)`">", "Here is my new line of text"} | |
Replaces: | |
<case match="AppleWebKit/(?'version'(?'major'\d)(?'minor'\d+)(?'letters'\w*))(.* )?(?'type'[^/\d]*)/.*( |$)"> | |
With: | |
Here is my new line of text | |
Before: | |
xml=true | |
tagwriter=System.Web.UI.HtmlTextWriter | |
<case match="AppleWebKit/(?'version'(?'major'\d)(?'minor'\d+)(?'letters'\w*))(.* )?(?'type'[^/\d]*)/.*( |$)"> | |
type=${type} | |
</case></case> | |
After: | |
xml=true | |
tagwriter=System.Web.UI.HtmlTextWriter | |
Here is my new line of text | |
type=${type} | |
Notice: you will need to escape any special characters used by powershell or RegEx (IE: using ` in front of the " used in the regex match pattern since the string's begin and ending are defined by "", and using \ in front of any () [] ? . * etc. etc. since these characters have special meaning in RegEx. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment