Search code examples
regexunit-testingfitnesse

Using regular expressions in Fitnesse to test currency values


Very new to Fitnesse, I need to write a test using regular expressions to test floating point precision...

$24.59   TEST: starts with '$' and precision is 2 decimal places 

I tried this but it did not work, thinking it's a syntax problem, I just need to get the regex expression correct, I don't need the full test fixture

/^$\d+.\d{2}$/

Solution

  • You need to escape the match-characters if you want match it on string. In this case, $ and ..

    /^\$\d+\.\d{2}$/