开发者

Regex search for Smarty template

开发者 https://www.devze.com 2023-03-22 04:16 出处:网络
I have some fields with names such as: home_phone company_phone mobile_phone other_phone_c personal_phone_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$)开发者_如何学JAVA}}"


Use this: .*_(?:phone|phone_c)$

It will match desired strings, which ends with _phone or phone_c.

0

精彩评论

暂无评论...
验证码 换一张
取 消