ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Using regular expressions in {if} conditionals

February 21, 2008 1:34pm

Subscribe [1]
  • #1 / Feb 21, 2008 1:34pm

    neolithic

    1 posts

    If I want to make sure a segment does not start with a specific range of characters, how can I use regular expressions to accomplish this? Here is an example.

    {if segment_2 == "/$P[0-9]/"}

    Statement

    {/if}

    In other words if segment_2 starts with P and any number 0 through 9, do statement.

    I thought from reading other posts that a regular expression in EEmachine was surrounded by / and /. But for whatever reason it is not working. Or is it even possible to use regular expressions in EE? I have version 1.5.2, will upgrade to 1.6.2 after I finish some cleanup work.

    Thanks

  • #2 / Feb 21, 2008 4:34pm

    Lisa Wess

    20502 posts

    Hi, neolithic - ExpressionEngine conditionals do not support regular expressions. You’ll need PHP for that.  You can read the documentation on conditionals here.

  • #3 / Feb 21, 2008 4:48pm

    neolithic

    1 posts

    Hi, neolithic - ExpressionEngine conditionals do not support regular expressions. You’ll need PHP for that.  You can read the documentation on conditionals here.

    Thank’s. Was hoping for a fast fix. Just have to do a little PHP programming then.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases