How to split a string into two parts then join them in reverse order as a new string?
问题 This is an example: $str="this is string 1 / 4w"; $str=preg_replace(?); var_dump($str); I want to capture 1 / 4w in this string and move this portion to the begin of string. Result: 1/4W this is string Just give me the variable that contains the capture. The last portion 1 / 4W may be different. e.g. 1 / 4w can be 1/ 16W , 1 /2W , 1W , or 2w The character W may be an upper case or a lower case. 回答1: Use capture group if you want to capture substring: $str = "this is string 1 / 4w"; // "1 / 4w