<?php $re = '/(?|(c)(hapters?))\s*((\d+(?:\.\d+)?(?:[A-Z]\b)?)(?:\s*(?:[,&+-]|and)\s*(?:\b(?:c(?:hapters?))\s*)?(?4))*)/ui'; $str = 'chapter 2.5 2 cái địt mẹ mày'; preg_match($re, $str, $matches); // Print the entire match result echo $matches[0];