Just wondering on how to test if a string contains on numeric characters.
I tried
$testdata = [
'ver' => '087'
];
$this->assertRegExp('/0-9/',$testdata['ver']);
but the above fails.
Just wondering on how to test if a string contains on numeric characters.
I tried
$testdata = [
'ver' => '087'
];
$this->assertRegExp('/0-9/',$testdata['ver']);
but the above fails.
All numbers would have to be:
^[0-9]+$
Ranges have to be enclosed in brackets. However, just [0-9]
is just going to match anything with one number.
You can also use \d
to represent any digit.
^\d+$
If you want to take advantage of PHP's is_numeric check, you could also perform the assertion this way:
$this->assertTrue(is_numeric($testdata['ver']));