Hi and welcome to forums,
You have two ways.
a. Store the string variable in to a hidden field in the form. And add a rule to the button to set the value. Follow the below steps to do that.
1. Go to button properties.
2. Click on Rules.
3. Click Add then click Add action.
4. Select ‘set a field's value' in action drop down, select rich text field in Field, select string value field in Value.
5. Click Ok until all the windows gets closed.
b. Add a button click event and store the string variable in to rich text field.