0

I am using powershell to automaticly add lines of code to certain scripts. See example below:

$a -replace '<div class="ef-column1 bodyContent" id="column1">', '<div class="ef-column1 body-content" id="column1"> @RenderSection("ColumnMainHeader", false)'

The @RenderSection part should be on a new line. So i tried to add 'n in front of @RenderSection but this will create 'n@RenderSection instead of putting @RenderSection on a new line.

I also tried 'r'n@RenderSection, but this has the same effect. putting 'n between " " will work neither.

2

1 Answer 1

2

The issue is with the single quote at the front making the grave a literal one rather than escaping the 'n.

Try using double quotes and then escaping all of the double quotes in the expression:

$a -replace '<div class="ef-column1 bodyContent" id="column1">', "<div class=`"ef-column1 body-content`" id=`"column1`"> `n@RenderSection(`"ColumnMainHeader`", false)"
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.