A
A
Adam Jensen2022-03-28 13:12:36
PHP
Adam Jensen, 2022-03-28 13:12:36

How can I use preg_match to find a word-bound string that contains a minus sign?

Syntax Smarty.

You need to determine exactly if the string contains one of the two words ( container or container-fluid ). In this form, for example , container-f returns false .

{if !preg_match('/\b(/container-fluid|container)\b/', $args['container']) !== false}
      {capture append='container'}
        container
      {/capture}
      {$container = implode(' ', $container)}
    {/if}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adam Jensen, 2022-03-28
@uid2695

Everything turned out to be easier than it seemed. Maybe someone will come in handy.
/\b(container$|container-fluid$)\b/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question