To add a working example, since this is a general question (without a good answer in SO) "
public function rules(){ ... array('price', 'match', 'pattern'=>'/^[0-9]{1,12}(\.[0-9]{0,4})?$/'), ...
where {1,12} is the range of integer digits, and {0,4} is the range of "under" units.
For a normal price range from 0.01 to 9999.99, use the regular expression as follows:
'/^[0-9]{1,0}(\.[0-9]{0,2})?$/'
ref: kitune in the Yii forums
source share