正则表达式搜索 Smarty 模板
我有一些字段的名称如下:
home_phone
company_phone
mobile_phone
other_phone_c
personal_phone_c
我有一个 Smarty 变量,用字段值填充输入值:
value="{$fields.{{$prefix}}_phone}"
但带有后缀 _c
的字段不会输出,因为它们与模式不匹配。
有没有办法附加某种正则表达式,以便它查找在 phone
之后或以 _c
结尾的值,例如:
{$fields.{{$prefix}}_phone{regex | ($|_c$)}}"
I have some fields with names such as:
home_phone
company_phone
mobile_phone
other_phone_c
personal_phone_c
And I have a Smarty variable to populate input values with the field values:
value="{$fields.{{$prefix}}_phone}"
But the ones with the suffix _c
are not outputting, since they don't match the pattern.
Is there a way to append some kind of regex so that it will look for values that either end after the phone
or with _c
, something like:
{$fields.{{$prefix}}_phone{regex | ($|_c$)}}"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用:
.*_(?:phone|phone_c)$
它将匹配所需的字符串,以
_phone
或phone_c
结尾。Use this:
.*_(?:phone|phone_c)$
It will match desired strings, which ends with
_phone
orphone_c
.