Has to work within Bubble’s “Find and Replace” function:
Lowercase followed by uppercase or number, insert space. (examples: “aB” becomes “a B”, “a2” becomes “a 2”.
A bunch of uppercase characters followed by a lowercase letter, insert space between the last uppercase letter and 2nd to last uppercase character. (example: “ABCdef” becomes “AB Cdef”)
Dash, insert spaces on both sides. EXCEPT when the dash is between numbers, do nothing. (examples: “a-b” becomes “a - b”, “2-2” doesn’t change, “a-2” becomes “a - 2”, “2-a” becomes “2 - a”)
A bunch of numbers and/or dashes together, insert space on both sides. (examples: “a2022b” becomes “a 2022 b”, “a2022-12b” becomes “a 2022-12 b”, “a2022–12b” becomes “a 2022–12 b”)
Anyone up for a brain challenge and have any ideas?
I did originally try to run a few of these separately and string them together but couldn’t get it to work. Maybe I’m doing this wrong, but stringing these find/replaces together only runs the 1st one for me? Figured it was just a Bubble limitation or something.
A better way to do this?
Please note I was assuming I had to make this one ugly function!
@keith: I’m not trying to build a better file name. I’m trying to make a file name more visually appealing (especially if it wraps).
@ALB - fair enough (though you could also just truncate to some number of characters and append “…” and the file extension [if desired]). “Just a thought” as that goody-goody Mike would say.
As for getting unexpected results: It’s veeery easy to mistype these patterns. Make sure you’re not getting errors by running in debug mode or inspecting the console.
But :find & replace is chainable and should work just fine if all your expressions are valid AND if your algorithm does what you think it should do.
To debug further: Take a sample filename as arbitrary text in a text element and build the chain step by step:
Compare each line to ensure what you think should happen is actually happening. Could be that the order of how things happen doesn’t yield exactly what you want for all or just some filenames…