How can I convert a list of names into a dictionary-tiddler representing a group? Using a regex-filter?

I have a list of names in the form of

   Albert Archman
   Bert Bowman
   Charles Cunningham
   ...

… in a textarea field
With various leading spaces and spaces in between

How can I convert it to a dictionary tiddler with

Albert Archman:
Bert Bowman:
Charles Cunningham:

It would be nice to also have the option to abreviate

Albert A:
Bert B:
Charles C:

This shall be part of the group widgets of my classroom suite and used for a groupmaker and a speakerlist which can be seen there

Are regular expressions the way to do this?
I tried
{{{ [{$:/temp/classroom/group!!prepare}search-replace:g:regexp[\n],[:\n]search-replace::regexp[$],[:]]}}}

But the result is \n in the text insead of a new line

For the first part, you can try this:

<$list filter="[[aaa]get[text]split[
]trim[]]">

</$list>

(yes, that weird linebreak should be there. There is some escaped character alternative that I always forget… something along the lines of \n but that ain’t it)

For the abbreviation of the family names, I think a relevant question is if the full name always follow that format, i.e TWO names? I’m not sure how to achieve the abbreviation but I still would think this is an important question to know.

1 Like

Its splitregexp[\n]

I would be tempted to create contact tiddlers with first and last names, rather than using a dictionary tiddler because you can extend it further.

Thank you @twMat

\function newline() [[:]] [charcode[10]] [charcode[13]] +[join[]]

<$button class="tc-btn-invisible">test 2
<$action-setfield $tiddler="$:/temp/group" text={{{ [{$:/temp/classroom/group!!prepare}search-replace:g:regexp[\n],<newline>search-replace::regexp[$],[:
]]}}} />
</$button>

yeah; the charcod operator does it!
Now for the trimming:
Filters for removing

  • leading zeros in each line
  • Middlenames
  • Abreviating the surname

Wanted.

   Albert Anton Archman
   Bert Bowman
   Charles Cunningham
   Doris D. Day
   ...

For privacy reasons here in schools even the surname should be abreviated… Otherwise our DSGVO General Data Protection Regulation - Wikipedia can get you into big trouble.

I now have a button (group widgets) that produces a usable dictionary-tiddler further, it seems to be easier to apply further formatting to the produced indexes in a second step: