Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将“5a”之类的模式转换为“5A”。此模式可能出现在较大字符串的开头或中间。我试过这个:
$string = preg_replace_callback("/(0-9)([a-z]) /", function($matches) { return $matches[1].strtoupper($matches[2]).' '; }, $string);
但它不起作用。没有错误 - 字符串保持为“5a”。你能看出我哪里出错了吗?
/(0-9)([a-z]) /
应该
/([0-9])([a-z]) /