TiddlerTweakPlugin: does the replace regexp support grouping?

21 views
Skip to first unread message

G.J.Robert

unread,
Nov 6, 2012, 9:48:40 PM11/6/12
to tiddl...@googlegroups.com
Hi Eric and all,

I was trying to use TiddlerTweakerPlugin to replace
===<linebreak>(\+\+\+\[SomeText\].+?===)
as the regexp syntax
\1<linebreak>===
that is, I want to swap the first instance of "===" and "\+\+\+\[SomeText\].+?===" which is enclosed inside the parentheses, and represented as "\1" in the replace target string.

However, TiddlerTweakerPlugin does not seem to recognize the grouping syntax of regexp to use the shortcut "\1" to represent the whole string to be kept, and in the result of replacement, "\1" appears literally. But I hoped that I can get
+++[SomeText]SliderContent===<linebreak>===

Is there any way around to get my desired result? Thanks!

Eric Shulman

unread,
Nov 6, 2012, 10:40:35 PM11/6/12
to TiddlyWiki
> I was trying to use TiddlerTweakerPlugin to replace
===<linebreak>(\+\+\+\[SomeText\].+?===)
> as the regexp syntax
\1<linebreak>===

> However, TiddlerTweakerPlugin does not seem to recognize the grouping
> syntax of regexp to use the shortcut "\1" to represent the whole string to
> be kept, and in the result of replacement, "\1" appears literally. But I
> hoped that I can get

You were VERY close! Instead of "\1" , "\2", etc., javascript regexp
uses "$1", "$2", etc. as replacement markers

Thus:
===<linebreak>(\+\+\+\[SomeText\].+?===)
replace with:
$1<linebreak>===

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
http://www.TiddlyTools.com/#Donations

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact

G.J.Robert

unread,
Nov 7, 2012, 3:37:42 AM11/7/12
to tiddl...@googlegroups.com
Hi Eric,

Thank you so much and thank God I raised my inquiry here, because I was going to give up and prepare to use complicated export/import procedures to modify an offline TiddlyWiki HTML file and then import the tiddlers back to TSpace... And your explanation saved my day. Thanks!

Eric Shulman於 2012年11月7日星期三UTC+8上午11時40分41秒寫道:
Reply all
Reply to author
Forward
0 new messages