PDA

View Full Version : Replace in File: Multiline


mweinberger
02-16-2006, 12:51 PM
Hi all,

I'm trying to replace a single line with multiple lines. If I press "Test", then all is fine, but as soon as I execute normally I consistantly get VBPro replacing my single line with nothing, effectively deleting the line. Here is some sample code.

==================
Source File To Operate On
==================
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

========================
Text or regular expression to find:
========================
</Project>

====================================
Text or regular expression to replace matches with:
====================================
(?1 <Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTas k\Microsoft.VersionNumber.Targets"/>
<PropertyGroup>
<AssemblyMajorVersion>1</AssemblyMajorVersion>
<AssemblyMinorVersion>0</AssemblyMinorVersion>
<AssemblyBuildNumberType>DateString</AssemblyBuildNumberType>
</PropertyGroup>
</Project>
)

What do you think the problem is and how do I work around this issue?

Thanks in advance,

M. Weinberger

mweinberger
02-16-2006, 01:19 PM
Playing with VBPro, I discovered the solutions.

1. I have to use parenthesis around the find expressions, so:

(</Project>)

2. I should use (for cleaner looking code) \r\n as new line characters in the replacement.

Hopefully this post helps somebody.

Me
ButterflyVista.com!