Forum How do I...?

Can I replace multiple strings with prince-text-replace

tinkermarz
I have some decimal fractions on the website that are (automatically calculated and) formatted like this: -0.5

As I want to generate a more human readable text out of the calculated fractions, I want to get rid of the preceding "-" and change to "." to a comma, so that the example from above would look like this: 0,5

prince-text-replace comes in handy, but only seems to be able to either remove the "-" or change the decimal seperator.

.replace_fraction
{
prince-text-replace: "-" "";
prince-text-replace: "." ",";
}

does only remove the minus sign.

I also tried to put one of the replacements in the container class, but that doesn't work either, because it replaces all the instances in the container, but not where it already replaces something else. E.g.

HTML:

<div class="mytext">
The result ist <span class="replace_fraction">-0.5</span>
</div>

CSS:

.mytext
{
prince-text-replace: "-" "";
}

.replace_fraction
{
prince-text-replace: "." ",";
}

Do you have any idea or suggestion, how I could solve this problem?

Thanks a lot in advance!
mikeday
You can apply multiple replacements:
prince-text-replace: "aaa" "bbb" "ccc" "ddd"

This example will replace aaa with bbb and replace ccc with ddd.
tinkermarz
Ah, thanks a lot. It works!