<?php $string = "numbers 42"; $pattern = "/[^0-9]$/"; if(preg_match($pattern, $string)) print("Found a match!"); ?>