Php 使用regex替换为smarty?
我认为我应该使用Regex在Smarty模板系统中进行替换,但我不确定。以下是原始输出:Php 使用regex替换为smarty?,php,regex,smarty,Php,Regex,Smarty,我认为我应该使用Regex在Smarty模板系统中进行替换,但我不确定。以下是原始输出: <input type=hidden name=item_name value="My Website - Invoice #53"> 我想做的就是删除末尾的数字,但每个发票ID都不同。以下是我想要的: <input type=hidden name=item_name value="My Website - Payment For Online Service"> 有人知道
<input type=hidden name=item_name value="My Website - Invoice #53">
我想做的就是删除末尾的数字,但每个发票ID都不同。以下是我想要的:
<input type=hidden name=item_name value="My Website - Payment For Online Service">
有人知道如何使用正则表达式或其他方法删除末尾的数字吗?使用
\d+
匹配一个或多个数字
{$code|replace:'My Website - Invoice\s+#\d+':'My Website - Payment For Online Service'}
<input type=hidden name=item_name value="My Website - Payment For Online Service">
{$code|replace:'My Website - Invoice\s+#\d+':'My Website - Payment For Online Service'}