Page 1 of 1

Adding Text to the End of a Line - Not Simple :)

Posted: Thu Oct 31, 2013 8:13 pm
by asistla
Hello All,

Have a question, I have the following line in a config file and I need to add some text to the end of the line. Problem is that there are 2 areas in the line , one where there is a client name (that changes in each config file) and the second where there is a client id number (also changes in each config file).

Here is the line:

"-ExecutionPolicy ByPass L:\LRO\CLIENTNAME\prog\scripts\EtlDailyLoadSchedule.ps1 -clientid CLIENTID"

I need this to say :

"-ExecutionPolicy ByPass L:\LRO\CLIENTNAME\prog\scripts\EtlDailyLoadSchedule.ps1 -clientid CLIENTID" defer="Y"

Thanks for your help.

Avi

Re: Adding Text to the End of a Line - Not Simple :)

Posted: Fri Nov 01, 2013 10:23 am
by DigitalVolcano
Try this -

Code: Select all

RegEx:
(-ExecutionPolicy ByPass.*)\r\n

Replace:
$1 defer="Y"\r\n
Try a file in the tester first! This will change every 'ExecutionPolicy ByPass' line, and assumes that your files use CRLF line endings.

Re: Adding Text to the End of a Line - Not Simple :)

Posted: Fri Nov 01, 2013 1:09 pm
by asistla
Thanks much for the help, we are very close.

The find is finding the right information:

-ExecutionPolicy ByPass L:\LRO\xxx\prog\scripts\EtlDailyLoadSchedule.ps1 -clientid 31" maxmins="60" start-hhmm="0300">

Problem is that there is an end bracket at the end of the line and it is placing the inserted defer after the bracket

-ExecutionPolicy ByPass L:\LRO\xxx\prog\scripts\EtlDailyLoadSchedule.ps1 -clientid 31" maxmins="60" start-hhmm="0300"> defer="Y"

I need the defer to go inside the end bracket.

Thanks again for your assistance.

Re: Adding Text to the End of a Line - Not Simple :)

Posted: Fri Nov 01, 2013 2:32 pm
by DigitalVolcano
If it is on every occurrence you could just replace the /r/n with the >

regex: (-ExecutionPolicy ByPass.*)>
rep: $1 defer="Y">


Or if it just happens in some places you could do a second pass with:

search: > defer="Y"
replace: defer="Y">

Re: Adding Text to the End of a Line - Not Simple :)

Posted: Fri Nov 01, 2013 6:18 pm
by asistla
Thank you guys very much for the assistance!