Using Twig, is it possible to strip out or replace a non-breaking space (
)?
I've got a string variable price
(returned from the currency
filter) that prints like this:
Nkr 100,00
What I'd like, is to strip the Nkr
part, so the string looks like this:
100,00
However, {{ price|replace('Nkr ', '') }}
does nothing, as the replace
filter doesn't appear to actually match the non-breaking space.
{{ price|replace({'Nkr' : ''}) }}
strips out the Nkr
part, but leaves the
; and I'm unable to remove it.
Here's what I tried already (after stripping the Nkr
part):
{{ price|replace({' ' : ''}) }}
{{ price|raw|replace({' ' : ''}) }}
{{ price|striptags }}
{{ price|raw|striptags }}
{{ price|trim }}
{{ price|raw|trim }}
{{ price|replace({ '\u00a0' : '' }) }}
{{- price -}}
{% spaceless %}{{ price }}{% endspaceless %}