Handlebars calculate string length after replace
Hello,
I'm trying to calculate the length of a string after I remove the whitespaces inside the string, in the screenshot bellow I need the second element to have a value 9 instead of the name. Can this be done with handlebars?
-
Official comment
Hey Hristina,
I thought of a pretty nifty workaround that will work super well.
We have a function called regexSearch which will compare a regular expression to a string and will return the index where the match starts. The regular expression "$" will match the end of the string. So if I just search for "$", it'll return the string length!
P.S. I really like the two "Bob"s that you and I chose haha
Thanks,
-Lucian -
Hi Hristina Bendeva,
You should be able to use #compare handlebar to check the length of a string. Check this community post. Let us know if you have other questions or this doesn't solve your issue!
0 -
Hi Courtney Jordan,
This doesn't solve my issue because I need to remove the whitespaces from the string before I check the length of the string.
0 -
Hi Lucian,
Thank you for the solution this is what I needed.
P.S both Bob's are legends in their own right.
Thanks,
-Hristina
0
Please sign in to leave a comment.
Comments
4 comments