Preserving formatting in find and replace
This month we are looking to fund preserving or changing formatting of found strings. This feature will optimize the coding process of find and replace in LiveCode saving you time and effort. Presently when trying to replace a string in a field all formatting would be lost without implementing a more time consuming workaround.
Preserving formatting in find and replace
The replace command is a staple of text manipulation in LiveCode. At present, its form is:
replace <string> with <replacement> in <target>
The command searches for the string <string>
in <replacement>
and then replaces any occurrences with the string <target>
. A long standing limitation of the command is that if <target>
is a field, then the styling on the text is removed.
We propose to add an implementation of the current command which performs the replace operations on the field ensuring formatting is preserved. The rule will be that any occurrences of <pattern>
in the field will be replaced by <replacement>
using the styling of the first character of the found instance of <pattern>
. For example, let us say field 1 contains:
the quick brown fox jumped over the lazy dog
Then
replace “the” with “THE” in field 1
Would result in
THE quick brown fox jumped over THE lazy dog
Benefits
This feature will optimize the coding process of find and replace in LiveCode saving you time and effort. Presently when trying to replace a string in a field all formatting would be lost without implementing a more time consuming workaround. We are proposing a find and replace strings in fields feature whilst preserving the formatting.
If this project is successfully funded we estimate that we will commence development in December with an estimated final delivery in early February 2016.
7 comments
Join the conversationDevin - November 19, 2015
May I suggest an option to preserve the current behavior? You could just add a ‘with formatting’ clause:
replace “foo” with “bar” in fld 1 with formatting
This nicely parallels things like:
import snapshot from [object] with effects
Massimiliano - November 20, 2015
I would change this project title to “a new replace command”.
If you don’t read all page project, you think that it’s related to the code editor.
Massimiliano - November 26, 2015
Hello,
is there any web widget to embed in other website to promote this campaign?
Malte - December 10, 2015
Done. 🙂
Steve - January 3, 2021
Was this ever implemented?
Heather Laine - January 5, 2021
Yes, it was. Check the dictionary for details, under the “replace” command.
Ifediogor Jefferey - December 28, 2021
preserving current behavior? I could just add a ‘with formatting’
clause:
replace “Alpha ” with “bar” in fld 1 with formatting
This nicely parallels things like:
import snapshot from [object] with effects