[TW5] Some string manipulation filters

111 views
Skip to first unread message

Jed Carty

unread,
Mar 30, 2019, 5:43:58 PM3/30/19
to TiddlyWiki
I was cleaning up some of the things I have been working on over the past few months and I found some plugins that I never released. The only one is a state that is reasonable to release has some filter operators for string manipulation. I am not sure how useful people will find them but the filter operators are:

spliton - takes input titles and divides them into separate titles splitting on an input string
joinwith - the opposite of spliton, it takes a list of input titles and joins them together into a single title with the parameter string between each one
uppercase - makes all letters in the input titles uppercase
lowercase - makes all the letters in the input titles lowercase
getprefix - takes the input and returns the first n characters from each title, optionally padding them to ensure that each output title is n characters long
getsuffix - takes the input and returns the last n characters from each title, optionally padding them to ensure that each output title is n characters long

It is available from the twederbob plugin library or from the public wiki here https://www.ooktech.xyz:8443/Public#%24%3A%2Fplugins%2FOokTech%2FStringFilters

The code is available on GitHub https://github.com/OokTech/TW5-StringFilters

TonyM

unread,
Mar 30, 2019, 7:46:51 PM3/30/19
to TiddlyWiki
Jed,

They look very helpful.

Perhaps they can feed into the construction of the proposed maths operators proposed in 5.1.20 because I expect there could be some overlap.

Regards
Tony

Mohammad

unread,
Mar 31, 2019, 1:18:26 AM3/31/19
to TiddlyWiki
Hi Jed,
 These are great! and as Tony said there is overlap with math operators in 5.1.20pre.
Have a look at


--Mohammad

TonyM

unread,
Apr 3, 2019, 11:16:41 PM4/3/19
to TiddlyWiki
FyI


In Jeremy's first post, I have underliened matching ones to jeds.

negate - negation
abs - absolute value
ceil - smallest integer greater than or equal to a given number
floor - the largest integer less than or equal to a given number
round - the value of a number rounded to the nearest integer
trunc - the integer part of a number by removing any fractional digits
sign - the sign of a number, indicating whether the number is positive, negative or zero
add - add an operand to every number in the input list
subtract - subtract an operand from every number in the input list
multiply - multiply every number in the input list by an operand
divide - divide every number in the input list by an operand
remainder - replace each item in the input list with the remainder when dividing that number by an operand
max - replace any number in the input list larger than the operand with the operand
min - replace any number in the input list smaller than the operand with the operand
fixed - formats a number using fixed-point notation with the number of fractional digits after the decimal point given by the operand
precision - returns a string representing the number to the precision specified in the operand
exponential - returns a string representing the Number object in exponential notation with the number of digits after the decimal point specified in the operand
sum - replaces the input list with the sum of all the entries
product - replaces the input list with the product of all the entries
maxall - replaces the input list with the maximum value of all the entries
minall - replaces the input list with the minimum value of all the entries
length - replaces each item in the input list with its string length in characters
uppercase - replaces each item in the input with its uppercase equivalent
lowercase - replaces each item in the input with its lowercase equivalent
trim - trims each item in the input list
concat - concatenates all of the items in the input list into a single string 
split - splits each of the items in the input list by a given separator
join - joins all of the items in the input list with a given separator see jeds joinwith


there is still an issue where the inputs have the duplicates removed

Jeds operators
spliton - takes input titles and divides them into separate titles splitting on an input string
joinwith - the opposite of spliton, it takes a list of input titles and joins them together into a single title with the parameter string between each one
uppercase - makes all letters in the input titles uppercase
lowercase - makes all the letters in the input titles lowercase
getprefix - takes the input and returns the first n characters from each title, optionally padding them to ensure that each output title is n characters long
getsuffix - takes the input and returns the last n characters from each title, optionally padding them to ensure that each output title is n characters long

Regards
Tony
Reply all
Reply to author
Forward
0 new messages