I have this string.
$string = 'product_posting_list_name_1';
I am using this to find the match but it is not finding the match. Can anyone explain to me why? I want to match up to the last underscore and the number.
preg_match('/\bproduct_posting_list_name\b/', $string)
_the underscore, is considered to be a word character, which is inside the boundaries you have placed via\b, not a boundary itself. Your regular expression is looking for complete words between boundaries, but the boundary occurs after the_1.To match it, you cannot use a boundary on the right side.