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.
我目前有这个:
$population = '1,601 (2001 census){{Census 2001 AUS|id=SSC12856|name=Palm Beach (State Suburb)|accessdate=30 June 2007|quick=on}}';
我要这个:
$population = '1,601 (2001 census)';
我已经尝试使用preg_match删除我想要的所有内容,但我无法弄清楚正则表达式。
preg_match
我将如何做到这一点?
第一次删除{可以吗?
{
substr($population, 0, strpos($population, '{')) # This would be better written strtok($population, '{'), as @mario points out.
或者,删除 and 之间的所有{{内容}}:
{{
}}
preg_replace('/{{.*?}}/', '', $population);