regex - Smarty Regular Expression Match -


i have smarty variable, want know if matches string like

"whatever_thestring_whatever"

something *_thestring_*

does know anyway this?

using smarty check if string exists inside string:

{assign "haystack1" "whatever_thestring_whatever"} {assign "haystack2" "whatever_thestrings_whatever"}  test haystack1 {if $haystack1|strstr:"_thestring_"}found!{/if}<br /> test haystack2 {if $haystack2|strstr:"_thestring_"}found!{/if}<br /><br /> 

output:

test haystack1 found! test haystack2 

or more complex search using regex in smarty:

{assign "haystack1" "whatever_thestring_whatever"} {assign "haystack2" "whatever_thestrings_whatever"}  {assign "check_haystack1" $haystack1|regex_replace:"/_thestring_/":" "} {assign "check_haystack2" $haystack2|regex_replace:"/_thestring_/":" "}  test haystack1  {if $check_haystack1 !== $haystack1}found!{/if}<br /> test haystack2  {if $check_haystack2 !== $haystack2}found!{/if}<br /> 

which has output:

test haystack1 found! test haystack2  

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -