Hi folks,
I’m searching for a way to return the first [n] characters from a string. In the first step I also need to filter out non-alphanumeric characters, so I decided to use a RegEx for this task.
While the RegEx works in the way I want I couldn’t find a solution to return only the first 20 characters of the output.
\define regexalphanum() [^A-z0-9\-_]
<$text text={{{[[{{TiddlerTitle!!Field1))//AndOther--Chars?!.}}]search-replace:g:regexp<regexnonalphanum>,[]]}}} />
Output:
TiddlerTitleField1AndOther–Chars
My guess is that there is a quantifier operator needed, but I didn’t figure it out how to use it right. It works with a string (tested at regex101.com), but unfortunately not in TW.
\define regexnonalphanum() [^A-z0-9\-_]
\define regexlimit20() [^.{20}]
<$let var1={{{ [[{{TiddlerTitle!!Field1))//AndOther--Chars?!.}}]search-replace:g:regexp<regexnonalphanum>,[]] }}} >
<<var1>><br>
<$let var2={{{ [<var1>regexp<regexlimit20>] }}} >
<<var2>><br><br>
Output:
TiddlerTitleField1AndOther–Chars
TiddlerTitleField1AndOther–Chars
Thank you in advance for your suggestions.