Search code examples
javaunit-testingtestingmockitoscalatest

With which symbol can I replace anyInt in "expected should equal("""anyInt - anyInt - anyInt""")"


I want to check if a date has the format "yyyy-MM-dd". date should equal("""anyInt-anyInt-anyInt""").

With which symbol should I replace anyInt in java?


Solution

  • Regex: \\d{4}-\\d{2}-\\d{2}

    \\d matches any digit (exactly one)

    {x} is number of occurrences

    \\d{4} => matches four digits

    \\d{2} => matches two digits

    etc.

    \\d+ => matches unlimited number of digits (at least one)

    \\d* => matches unlimited number of digits (zero or more)