This is a modified version of sunstr proposed by Jed and it works amazing!
\define substr(string, start, length)
<$list filter="[<__string__>!is[blank]]+[<__start__>!is[blank]]"
variable=ignore>
<$vars Length={{{ [[$length$]!is[blank]then[$length$]]~[[$string$]length[]]
}}} >
<$text text={{{ [<__string__>split[]butfirst<__start__>first<Length>join[]]
}}} />
</$vars>
</$list>
\end
<<substr "This_is_a_Test" 1 3>>
<<substr "This_is_a_Test" 5>>
<<substr "This_is_a_Test" -5>>
<<substr "This_is_a_Test" -10 6>>
The two inputs *string *and *start* are required and the last input, *length
*is optional.
Macro checks if the first two parameters are missing!
It gives amazing but correct results! Give a try in tiddlywiki.com.
Note to the minus value for start and It takes characters from the end!
--Mohammad
--
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/95b95f26-14a0-4fea-a459-476b7ee93479%40googlegroups.com.