# Decimals

Watch the explanation for this recipe in the video Check The Element Contains A Number That Ends With Two Decimals (opens new window).

# Two decimals

Let's confirm the element has text that ends with two decimal numbers.

<div id="amount">1,465.30</div>
1,465.30
cy.contains('#amount', /\.\d\d$/)

# Optional zero last decimal

Sometimes the last digit is optional, if it is zero.

<div id="amount">1,465.3</div>
1,465.3
cy.contains('#amount', /\.\d\d?$/)

Tip: In Cypress v12 you can get the text of the element and invoke the regular expression match method, see cypress-map (opens new window)