StoreCenter Help : Online Editor : Variable Actions Samples : Removing trailing carriage returns
Removing trailing carriage returns
An invitation card can contain the address of the event and additional data such as the start and end date. If all of this data is inserted in the same frame and for the address a 'long text' variable is used, you may run into the following problem: if the user enters the street name, number, postal code and city in the address field and presses the ENTER button after typing the city name, the invitation has a blank line of text between the city and the start date of the event.
A variable action can be used to remove such trailing carriage return(s) and other unwanted content. This is done by using the original variable for data entry, copying a cleaned-up version of the content to the second variable and using that second variable in the document:
Assuming 'address' is the name of the forms variable, create a second 'Long Text' variable called 'address_final'.
Make this variable invisible and insert it in the text frame in the layout.
Add an 'On change' action in the original 'address' variable to replace undesired returns and full stops by a blank string.
Action code: to remove trailing carriage returns
1 set variable address_final value = stringFunctions replaceRegExp string: variable address value
2 regexp: string [\r\n]+$
3 replace string <blank>
Action code: to remove trailing carriage returns, other unwanted returns and full stops
1 set variable address_final value = stringFunctions replaceRegExp string: variable address value
2 regexp: string ^[\r\n]+|\.|[\r\n]+$
3 replace string <blank>
doc. version 6.0.4