Subtracting one selector from another - Cannot convert to number

Hello, I am trying to pull up a website and automatically subtract one selector from another. The code below mostly works but when the selector is used, any characters that aren't numbers cause an error. I figured out a way to handle the "$" character but ","'s are also causing issues, and using Split probably isn't the best way to handle that.

For example, if the selectors return the values 3,058.76 - 3,048.59, it gives the error Difference between Original and Updated Cannot convert "3,058.76" to a number. If manually remove the "," from the form it works, but it's less than ideal.

Any ideas on how I should update the code to handle this?

Form and Code
Below you will find the Original Invoice and Updated Invoice totals and the difference between them.

Original Price: ${formtext: name=Orig;default={={=split({site: text; selector=.col-md-6:nth-child(1) tfoot .text-right}, "$")[2]}}}
Updated Price: ${formtext: name=Updated;default={={=split({site: text; selector=.col-md-6:nth-child(2) tfoot .text-right}, "$")[2]}}}

Difference between Original and Updated {=Orig - Updated; format=$.2f}

Webpage example
Origvsupdated

Use a regular expression to remove any of the invalid characters, For example:

{value="$1,234.56"}
{value_clean=replaceregex(value, "[^0-9.]", "", "g")}
Value: {=value}
Cleaned value: {=value_clean}
Do some math: {=value_clean + value_clean}

This worked perfectly! Thank you!

Another question -

Is there a way to press a couple of keys and do something like open a URL or does there always need to be something typed to trigger the snippet?

Hi @Sylvia_Blanco,

Could you please give me more details about what you're trying to achieve with this?

If it's just a question of using Text Blaze to insert a link and visit it, you can insert a snippet directly in the URL bar.

Here's how that works:

If you can give me more details, I'm happy to help :slight_smile: