Search code examples
regexfitnesse

Regex issue in fitnesse


I am having trouble using regex in fitnesse. I want to get a regex for a sequence of 10 digits. I tried the following-

=~/\d{10}/ 

and

=~/[0-9]{10}/

But these are not working. For a sample input say "1234", the above regex is passing as green.

What would be the regex to test a sequence of 10 digits in fitnesse?


Solution

  • Try adding start/end anchors, e.g.

    =~/^\d{10}$/
    

    or perhaps word anchors if the 10 digit number is embedded in other text:

    =~/\b\d{10}\b/