[英]Check string matching with regular expression within PHP/Smarty-Template
I want to check within an if query whether a particular string (WBT) occurs in a string and responds to it. 我想检查是否在查询中是否在字符串中出现特定字符串(WBT)并对其作出响应。 I know that it is possible to work with regular expressions within Smarty templates, but it is not clear with the suggestions from the documentation . 我知道可以在Smarty模板中使用正则表达式,但是文档中的建议尚不清楚。
Here is the code where I need the regular expression to check if the string WBT occurs in it: 这是我需要正则表达式检查其中是否出现字符串WBT的代码:
<div class="card-content" style="text-align: center;">
[{if $woche.lehrskript}] // Check if "WBT" occurs in the string lehrskript
<strong>WBT</string>
[{else}]
<strong>[{$woche.lehrskript.name}]</strong>
[{/if}]
</div>
Can someone help me please? 有人能帮助我吗?
我已经这样解决了:
[{if strpos($woche.lehrskript.name, 'WBT') != false}]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.