Announcement: SNR
This is a simple script, search-n-replcae (snr) to search in tiddler contents (including all fields) for a searchValue and replace them with replaceValue.
<pre><$view field="text"/></pre>
It won't interfere with the code. BUT be aware, that doesn't work with tiddlers used as templates!!!!!!
have fun!
mario
MohammadReally excellent. Its working well and I haven't been able to get it to fail. It will have huge use I am sure.I do think an issue is UNDO.Let me show why ...
On a balmy day SHE took advice that HE needed to walk.If we replace "SHE" with "HE" we get ...
On a balmy day HE took advice that HE needed to walk.But it can't easily be reversed just switching "find" & "replace" terms as you'd get ...
On a balmy day SHE took advice that SHE needed to walk.
I think the simplest way to deal with this is that a Tiddler under s-n-r is cloned to a state tiddler before changes occur that can be RESTORED.What do you think?Best wishesJosiahCould the tiddler/s you working on be
On Thursday, 28 February 2019 07:54:26 UTC+1, Mohammad wrote:
Announcement: SNR
This is a simple script, search-n-replcae (snr) to search in tiddler contents (including all fields) for a searchValue and replace them with replaceValue.See the original post here!
--Mohammad
MohammadReally excellent. Its working well and I haven't been able to get it to fail. It will have huge use I am sure.I do think an issue is UNDO.Let me show why ...
On a balmy day SHE took advice that HE needed to walk.If we replace "SHE" with "HE" we get ...
On a balmy day HE took advice that HE needed to walk.But it can't easily be reversed just switching "find" & "replace" terms as you'd get ...
On a balmy day SHE took advice that SHE needed to walk.
I think the simplest way to deal with this is that a Tiddler under s-n-r is cloned to a state tiddler before changes occur that can be RESTORED.What do you think?Best wishesJosiah
Could the tiddler/s you working on be
On Thursday, 28 February 2019 07:54:26 UTC+1, Mohammad wrote:
Announcement: SNR
This is a simple script, search-n-replcae (snr) to search in tiddler contents (including all fields) for a searchValue and replace them with replaceValue.See the original post here!
--Mohammad
Diego Mesa wrote:In my mind, an "undo function" is synonymous with "version control".
I agree. Kinda. Though likely more short term than normal VC.
Mohammad wrote:But I am afraid duplication tiddlers in this way will result in huge file size.
I agree it would if it were persistent. I'm thinking more of cloning of just a "start version" that persists only as long as you doing the replace. That when you finish and happy ts deleted?Best wishesJosiah
This is such a good tool Mohammad!I ask a final, probably, very difficult, question ...Can we match CARRIAGE RETURNS? And can we INSERT them in replacement strings?Here is a simple example ...
<pre>The man was on the burning deck
His light was dim
And he got bogged.</pre>To do that you need to replace the HTML tags and remove excess carriage returns and replace with WikiText and insert carriage returns to get...
```
The man was on the burning deck
His light was dim
And he got bogged.
```Could this be possible?
Just wonderingBest wishesJosiah
This is such a good tool Mohammad!I ask a final, probably, very difficult, question ...Can we match CARRIAGE RETURNS? And can we INSERT them in replacement strings?
BTCThat is good news!!Rather than have a text area could it be done via substitution?
I'm thinking of the complexity of the interface to have a text area just for that.For instance could, with the example I gave, this work through the simple input fields ?...Search ...
\r\r<pre>
Replace ...
\r```\r
Just thinking out loudBest wishesJosiah
Announcement: SNR
This is a simple script, search-n-replcae (snr) to search in tiddler contents (including all fields) for a searchValue and replace them with replaceValue.See the original post here!
--Mohammad
Hi Mohammad, thank you, that looks very useful!Regarding carriage (really?) returns, Josiah and BTC,I would prefer a textarea that looks like an input field – but with the option to expand when needed. Like so:<$edit-text tiddler="test" field="demo" tag="textarea" rows="1" autoHeight="yes" minHeight="1.75em"/>
Ciao MohammadI'll do lots of testing of SNR2 on http://kookma.tiddlyspot.com/ and report back. It looks very good and very powerful!The is one BUG I found already. You can easily see it. Just enter ">" in the search box and it breaks the script like this...Best wishesJosiah
Many thanks. I will upload a new update.
I fixed the issue. I appreciate your time for evaluating the code and welcome your write up.
Best
Mohammad
This is a footnote. Just FYI.Regular Expressions are one of the few things I understand well.So IF anything I write about them seems difficult to understand please ask for clarification.Best wishesJosiah
MohammadThe issue is simply that we can get the MATCH well. But on REPLACE we might need to INSERT additional things that MATCH can't do.Hope this is clear!Josiah
Ciao MohammadI request that the m flag be enabled to be toggled ON.In some ways it might be better if m mode were the DEFAULT as its far less dangerous than g .FYI, I found it quite easy to get it run using "m" flag just by changing the JS code from "g" to "m" ... like this ...Would this be possible?Best wishesJosiah
Mohammad & all interestedI have done a lot of testing of "s-n-r2". It is very good!DIFFERENCES FROM NORMAL REGEXIt differs from normal regular expressions in that TiddlyWiki needs to guard itself from eating itself.It does this by needing the regex to be wrapped in Quote Marks.The type of quote marks differ according to the use-case.IF a tiddler only contains ' then wrapping in " will work. And vice-versa.IF a tiddler contains both ' and " quotes then the match string is easiest enabled by wrapping it: """regex""" .LIMITS1 - I have found NO WAY to safely make changes in a tiddler that contains the string """ . Those 3 double quotes are likely protecting TW from itself but the regex can't currently cope with them.That rules out safe s-n-r via regex in many macros.2 - SUBSTITUTION. Mohammad and I found out that there is currently no easy way to get Control Codes into output replaces. This is problematic as, for instance, we need to replace <pre> with \n```\n . BUT in replace the "\n" is only treated as a literal.Best wishesJosiah
M,In particular, multi-line mode is excellent! Great news!It allows step by step changes.J.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/4aacaf40-2a40-43f2-a5ce-37a0ad33a1dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mohammad,Excellent!An issue. You should not have Multi-line AND Global BOTH enabled!They are mutually exclusive.Best wishesJosiah
Diego,You are right. It does look odd. But it IS working fine. The reason why it appears odd is ...-- you run in "multi-line" mode and that means the match string always matches to first point that matches in the field. In this case the last two letters of This".-- because your match ="is" and replace ="is not" no difference will show for "is" as you don't change it.-- the "walking" green insertion is due to limits in the "difference" engine that doesn't always know on repeated words quite where to display the change.It is actually happening directly next to "This".Hope this is clear!Josiah