If we had a regular expression splitter (e.g. PR2963), then you could trim out prefix, suffix, or even create multiple splits from one input string. This would save having to create multiple filters for manipulating strings, especially since any new string operators would have names very similar to existing operators.
On Tuesday, June 30, 2020 at 10:21:37 AM UTC-7, Eric Shulman wrote: > > Hi all, > > In a discussion earlier today ( > https://groups.google.com/forum/#!topic/tiddlywiki/M8PFeakbp6U), there > was a "problem" caused by the use of [removeprefix[...]]. > The OP had assumed that this just removed the specified leading text from > the items being filtered when, in fact, it also does the matching action of > [prefix[...]] > > However, it would be helpful if there was a filter actually did *just* > remove leading (or trailing) text, > without regard to any matching. One example of a filter that does this > kind of non-matching action > is "[trim[]]" (introduced in 5.1.20), which removes leading/trailing > *whitespace* from the input items, > but doesn't have any effect on items that don't have leading/trailing > whitespace. Thus, a filter containing this: > > [[ foobar ]] [[mumble]] [[gronk snork ]] [[ frotz]] +[trim[]] > becomes just > [[foobar]] [[mumble]] [[gronk snork]] [[frotz]] > > My thought is this... we could extend the current *[trim[]]* syntax to > only remove leading > OR trailing whitespace by adding a suffix to the operator: > > *[trim:prefix[]]* would remove only leading whitespace > *[trim:suffix[]]* would remove only trailing whitespace > > and enable removing of other leading/trailing text values, not just > whitespace, by adding a parameter to the operator: > > *[trim[foo]]* would remove leading/trailing text "foo" > *[trim:prefix[foo]]* would remove only leading text "foo" > *[trim:suffix[foo]]* would remove only trailing text "foo" > > The parameter would also be able to handle repeating text. Thus, you > could trim a list of "zero-padded" numbers, like this: > [[123]] [[0.004]] [[0007.0]] [[000089]] [[27.00]] [[05.00]] +[trim[0]trim: > suffix[.]] > would produce this result: > [[123]] [[.004]] [[7]] [[89]] [[27]] [[5]] > > and something like: > [[ this is some text... ]] +[trim[ ]trim[.]] > would produce this result > [[this is some text]] > > I can think of several instances where such a filter could have saved me > untold amount of > effort in handling variations on field values entered by users via an > $edit-text widget > > Your thoughts? > > -e > > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/3e808675-aea8-46a1-97bd-2255be879f86o%40googlegroups.com.

