Arno Nühm Active member Apr 19, 2021 #1 I would like to strip all special characters from $__globals.thread.title variable. $__globals.thread.title|replace("/[^0-9a-zA-Z \-\_]/", "") doesn't work. How can I do this?
I would like to strip all special characters from $__globals.thread.title variable. $__globals.thread.title|replace("/[^0-9a-zA-Z \-\_]/", "") doesn't work. How can I do this?
P Paul B XenForo moderator Staff member Apr 19, 2021 #2 I don't think regex is supported in the template filter function. It likely needs to be a literal string, or an array. Upvote 0 Downvote
I don't think regex is supported in the template filter function. It likely needs to be a literal string, or an array.
P Paul B XenForo moderator Staff member Apr 19, 2021 #3 This is a bit meh but it works. HTML: <xf:set var="$specialChars" value="{{ ['ç', 'ş', 'ö'] }}" /> <xf:foreach loop="$specialChars" value="$char"> <xf:set var="$thread.title" value="{{ $thread.title|replace($char, '') }}" /> </xf:foreach> Obviously you need to define the array of special chars so it's not ideal. Upvote 0 Downvote
This is a bit meh but it works. HTML: <xf:set var="$specialChars" value="{{ ['ç', 'ş', 'ö'] }}" /> <xf:foreach loop="$specialChars" value="$char"> <xf:set var="$thread.title" value="{{ $thread.title|replace($char, '') }}" /> </xf:foreach> Obviously you need to define the array of special chars so it's not ideal.