I spent weeks trying finding out why my API calls were resulting in error where the quotation mark and comma to end an expression was being pushed to the next line. This was being caused by users entering trailing spaces accidentally into the text fields (possibly after pasting something in).
Support suggested that I use the find and command function to find and replace spaces in the usual way of entering in space/line break with the quotation and comma in the find field then deleting this space leaving just the quotation and comma in the replace field.
The issue I’m facing is that it works well if the user only leaves a single space in the field, because the search and find function assumes only a single space has been left. I’ve been trying various regex expression I Googled so that all trailing spaces, including line breaks should be deleted, but they haven’t seemed to make a difference.
This is what I’ve tried that hasn’t worked for me:
As someone that’s not that good at regex, I’ve found ChatGPT to be really helpful in this regard. Feed it examples of stuff your users are entering, say what you need it to do, and try it out in https://regex101.com/ to see how it does.
I can’t use the JSON-safe function because that switches up the JSON output altogether, but I’ve pre-formatted the JSON in Bubble which works for me.
In terms of :trimmed option, thanks for pointing to this. It looks like a robust way of preventing all sorts of spaces and line breaks. Seems to be working well at the moment in a limited testing environment.
I also realised whilst investigating this issue that Bubble may not display trailing spaces in the Rich Text Editor in the front end reliably. It would show trailing line breaks (or possibly spaces) in the back-end data tab. What ever was in the backend data tab, was in fact the true representation of how the data was structured - and because there were line breaks, it would result in errors - despite first glance from the data in the front end indicating no issue. I sent the issue back to support if they want to use my app to look into it further.
I tried to use my arrow keys to move the cursor as far as it would go to the right and down as to move onto a new line (if there was a line break there). But it didn’t do either. This is as far the cursor will go right
And this is the data tab - with the cursor sitting at the line break for the same field (I’d expect to see it to the right of the question mark as per the form):
You are right about the JSON-safe expression, and I would like to use it, but my integration is expecting the format to be like this (which is how I written it out in Bubble