filter: replace with regexp?

72 views
Skip to first unread message

Jean-Pierre Rivière

unread,
Sep 22, 2020, 5:55:48 PM9/22/20
to TiddlyWiki
I'd like to modify some titles via a filter using a regexp. More precisely, I'd like to transform things like R42 or TH37 in R or TH.

in bash I would do
echo $title | sed -e 's/\d+$//'

in TW I found rgexp to match titles but nothing to modify via a regexp. Or anything that could be used for my purpose. How should I proceed?

One I got those suffix like R or TH, I pla to use a dictionnary to transform them into the bits of URL I am trying to build.

In my previous attempts, I used the prefix operator, but this imply to know the prefix. Here, I don't want to know it and so cannot use the prefix operator.

TIA!

Jean-Pierre Rivière

unread,
Sep 23, 2020, 4:00:37 AM9/23/20
to TiddlyWiki
Thanks to an other post on the list, I've been able to solve my problem.

First, the solution: using the splitregexp filter operator!

example: (transform something like "SVR203" into "SVR")

<$set name="codeFamily" filter="[[$ref$]splitregexp[\d+]join[]]">

Now, the cause of my trouble: Looking for a regexp, I seartch into the string operators. Only had a glance at other operator afterwards. Missed that splitregexp operator in the middle of the first batch of operator (which have no general purpose given like strings operators for instance). Only saw the regexp operator, which was not what I needed.

Suggestion: the regexp operator notice could hint at the splitregexp operator!
Reply all
Reply to author
Forward
0 new messages