general substring possible?

190 views
Skip to first unread message

Gerald Weis

unread,
Mar 27, 2020, 2:34:17 AM3/27/20
to TiddlyWiki
hi all

I have an new projekt where i need an general substringfunktion

the makro should work at the pattern "fieldname"  "starting characternumer which should be extracted" "last charcternumber wich should extracted"

the most used field is the field "title" of the current Tiddler.
but other fields of current tiddlers should be possible to for use.

this substring must be printet in an other field as string.

my skill ist not so good.


thanks for ideas

TonyM

unread,
Mar 27, 2020, 7:15:42 AM3/27/20
to TiddlyWiki
Gerald,

It would be good if you gave a sample string and the result.


Any filter can be used to do this, but the triple braces are quick and easy

\define source-field() title
<$set name=string value={{{ [all[current]get<source-field>] }}}>


;Is one or some of these what you want?
:First Character = {{{ [<string>split[]first[]] }}}
:Last Character = {{{ [<string>split[]last[]] }}}
:Count = {{{ [<string>split[]count[]] }}}
:Length = {{{ [<string>length[]] }}}


;This is what split does, notice it removes the spaces (but not with count)
{{{ [<string>split[]] }}}

</$set>


Regards
Tony

Gerald Weis

unread,
Mar 27, 2020, 7:51:43 AM3/27/20
to tiddl...@googlegroups.com
Hi Tony

example-String

That is a new testversion

now i want it mak to a new (shorter )string

<<substring title start end>>
<<substring "title" "9" "10"> Member for this <<substring "title"  "16" "19">>

should given "a Member for this test"

the number of characters could be mutable

Hubert

unread,
Mar 27, 2020, 8:23:37 AM3/27/20
to TiddlyWiki

Gerald Weis

unread,
Mar 27, 2020, 9:19:12 AM3/27/20
to tiddl...@googlegroups.com
Hello Hubert

i don't anderstand the solution from jed

My Problem is the best to see in a date

this is an example-title of a tiddler
Titel Titel Titel 2020-03-12


now to example i want to have.
Mister XY was writing on: 12.03.2020 or.
Mister XY was writing on: 12.03.
Mister XY was writing on: 12.


this date should will use in a textfield of a tiddler

then the Values of extraxcted string i need in an variable that should be show

Hubert

unread,
Mar 27, 2020, 9:35:57 AM3/27/20
to TiddlyWiki
I'm not quite sure what you're trying to accomplish.

To split your input (2020-03-12) you can use the split[] operator and to replace the dash (-) with a point (.) you can also use join, like for instance:

<$list filter="[[2020-03-12]split[-]join[.]]">

</$list>

Thanks,
Hubert

On Friday, 27 March 2020 13:19:12 UTC, Gerald Weis wrote:
Hello Hubert

i don't anderstand the solution from jed

My Problem is the best to see in a date

this is an example-title of a tiddler
Titel Titel Titel 2020-03-12


now to example i want to have.
Mister XY was writing on: 12.03.2020 or.
Mister XY was writing on: 12.03.
Mister XY was writing on: 12.


this date should will use in a textfield of a tiddler


Gerald Weis

unread,
Mar 27, 2020, 9:44:55 AM3/27/20
to tiddl...@googlegroups.com
hallo Hubert

i use a template-tiddler.

{{||Körpertyp-Radiobutton}}

ithis i do if the radiobutton no works as Macro

Now i must have that fProblem that all definitions must be for the currenttiddler.
And the date that you see in the format YYYY-MM-DD i must have in the format DD.MM.YYYY

i cant also set the date in the list-filter-definition.


The best way to filter ist the substring-filter of EXCEL substr(fieldname, startcharacternumber, numbers of characters)


at excemple

Text before split: Das ist ein Text

substr(<currentTiddler>, 1, 7>

Text when split done: Das ist

what now?

Gerald Weis

unread,
Mar 29, 2020, 4:01:01 AM3/29/20
to TiddlyWiki
Hi Toni,

Can i use some of this paramters in one Makro

an how can i do this.

an Macro with the colon i dont have seen till this day

Am Freitag, 27. März 2020 12:15:42 UTC+1 schrieb TonyM:

TonyM

unread,
Mar 29, 2020, 6:50:07 AM3/29/20
to TiddlyWiki
Gerald,

Sorry I find it hard to follow your Questions. I am Guessing is German yourNative Language?

We have people here that speak German, there is a french group and more. Perhaps ask for help in a new thread in your native language eg give it a tile like this;

[german Speakers] Question in German

Regards Tony
Reply all
Reply to author
Forward
0 new messages