We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Invalid regular expression

How Do I?

Tansel's avatar
Tansel
32 posts
9 years ago
Tansel's avatar Tansel

The conditional below gives “invalid regular expression” error in EE 2.10.1

I am just trying to check if segment_4 is exactly 32 long string comprised of letters and digits.

{if segment_4 ~ "/^[a-zA-Z0-9]{32}$/"}

What could be the fix?

       
Derek Jones's avatar
Derek Jones
7,561 posts
9 years ago
Derek Jones's avatar Derek Jones

I confirm, S-Cube, it thinks your length range of {32} is an unparsed ExpressionEngine variable. Looking into solutions that don’t require writing and maintaining a regex parser. 😉

       
Derek Jones's avatar
Derek Jones
7,561 posts
9 years ago
Derek Jones's avatar Derek Jones

And I realize how ridiculous this looks, but as a workaround to get you past this:

{if segment_4 ~ "/^[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]$/i"}
       
Tansel's avatar
Tansel
32 posts
9 years ago
Tansel's avatar Tansel

Thanks a lot Derek, it worked great. 😊

I was just trying to add extra strength to search/results pages with this.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.