for example, str = "123456789" regex = "\\d{9}|\\d{4}" then regex_search, will return "1234", not "123456789"