How Can We Help?
< All Topics
How can I replace all hard returns in a variable with something else like “<BR>“?
UpdatedJune 28, 2022
There are two ways to do this:
- If you can copy the characters representing the hard return into the clipboard, then you can paste them into the “Text to Replace” field of the “Replace “_” with “__” in %T1%” macro command.
It is not always possible to copy a hard break to the clipboard so you may need to use the second method.
- If you can copy the characters representing the hard return into the clipboard, then you can paste them into the “Text to Replace” field of the “Replace “_” with “__” in %T1%” macro command.
- Use the “Variable Set %T9% to ASCII Char of __” macro command to put the value of the hard return into a string variable. You can then put the variable, in this case %T9%, in the “Text to Replace” field of the “Replace “%T9%” with “__” in %T1%” command.
The challenge with this method is determining the value of the hard return. Some programs may use a Carriage Return (CR), others may use a Line Feed (LF), and still other programs may use both a CR and a LF. While less common, it is also possible that a program may use a completely different value for the hard return.
The ASCII value for CR is 13 and the ASCII value for LF is 10.
Here is an example of how to accomplish this if the hard return is CR LF. This method requires that you make two substitutions:
Variable Set %T8% to ASCII Char of 13
Variable Set %T9% to ASCII Char of 10
Replace “%T8%%T9%” with “<BR>” in %T1%
– Applies to: Macro Express and Macro Express Pro