How to add a new line in Replace Text


  • Joined: Jan 7, 2010
  • Posts: 21

Thu 6/3/2010 - 15:21

I'm trying to use the Replace Text action to add variables to a PHP file. I want each new variable to be on a new line. The way I have it setup is like this:

$variable1 = "whatever";
//add new var

I replace the text "//add new var" with the new variable to be added. But I also need to add "//add new var" on the next line so as to add other variables in the future.

I tried something like this, Replace With: $variable2 = "whatever2";\n//add new line

But it doesn't make \n into a new line. I tried checking the box "Use Regular Expressions for find and replace" but got the same result. Is it possible to make a new line using the Replace Text action?



  • Joined: Jan 12, 2010
  • Posts: 204

Fri 6/4/2010 - 13:42

 Hello there! You cannot use \r?\n in the replacement string of regular expressions (you can see that if you try to do a replacement with \r?\n in Expresso) . There are 2 alternatives that you may want to consider:

- You can use the "Append Line To Text" action (under "Text Actions" category):
Most people don't know the specific action and it can help you with the issue that you are facing.

- You can also use the "Split Text" action with custom delimiter (i.e. the text that you want to replace) and "Join Text" with standard delimiter (i.e. NewLinex1).



  • Joined: Jan 7, 2010
  • Posts: 21

Tue 6/8/2010 - 12:00

Hi, thanks for your reply! At first I wasn't quite sure how to implement the "Append Line To Text" action to accomplish what I needed. I hadn't thought about using it to append the new line to the variable I'm adding to the file. When I did it like that, it worked perfectly.

So to anyone who may stumble upon this thread and isn't sure about "Append Line To Text", I'll try to give a brief example:

"Set Variable"
Set Value: $link2 = "";
into Variable: %NewLink%

"Append Line To Text"
Original Text: %NewLink%
Line to Append: // add new link
Store Result Into: %NewLink%

Then Replace Text: // add new link with %NewLink%

$link1 = "";
// add new link


$link1 = "";
$link2 = "";
// add new link

Thanks D.M.Altizer



  • Joined: Jan 12, 2010
  • Posts: 204

Wed 6/9/2010 - 11:20

 Glad that I could help :)

I think (and I say that without providing any guarantee at all :P) that the "Replace With" field of the "Replace Text" action will become a multi-line field allowing you to enter something like the following:


and replace the text that you selected with a new line character. This is not a part of the first beta that has been released but it was mentioned by an employee of the support department in one of the emails that I sent to them.

Not a member yet? Register

Copyright 2014 - Softomotive Ltd