I'm unable to remove a Unicode character from a string. In the following twig template.
{% include 'components/accordion.twig' with {
this: {
id: program.slug,
active: (loop.index == 1) ? true : false,
header: header,
body: body,
cta: {
href: program.get_permalink,
text: __('Learn More', 'accessnyc-locations')
}
}
} only %}
{% endfor %}
The programs.slug
returns a string with the Unicode %e2%80%8b
"aria-c-senior-citizens-rent-increase-exemption-%e2%80%8bscrie"
From the following Stackoverflow post it seems that the %e2%80%8b
is somehow added to the string. When I try to replace it from the string the output string still the same. The correct output should be
"aria-c-senior-citizens-rent-increase-exemption-scrie"
I tried using replace(/\u200B/g,'');
as shown in this example, without success. How can I go about removing Unicode characters from a string?
here is what I tried:
program.dataset.id = program.id.replace('/[\x00-\x1F\x7F]/u', 'cookie');
"aria-c-senior-citizens-rent-increase-exemption-%e2%80%8bscrie"
program.dataset.id = program.id.replace('/[\x00-\x1F\x7F]/u', '');
"aria-c-senior-citizens-rent-increase-exemption-%e2%80%8bscrie"
program.dataset.id = program.id.replace('/[\x00-\x1F\x7F]/', 'cookie');
"aria-c-senior-citizens-rent-increase-exemption-%e2%80%8bscrie"
i also tried
{% autoescape %}
{% include 'components/accordion.twig' with {
this: {
id: {{ programs.slug|raw }},
active: (loop.index == 1) ? true : false,
header: header,
body: body,
cta: {
href: program.get_permalink,
text: __('Learn More', 'accessnyc-locations')
}
}
} only %}
{% endfor %}
{% endautoescape %}
How can I go about removing these from the string?