0

I use in a EE site Structure and Low events. I need to use switchee but I can't find the correct regex for a date format like this: yyyy-mm I use quit often this switchee regex: {case value="#^P(\d+)$#|''"} for paging but I just can't find it for I need: {case value="yyyy-mm|''"}

1

For a not too specific match try:

{case value="#\d{4}-\d{2}#"}

which would match 4 digits ( \d{4} ) then a dash ( - ) then 2 digits ( \d{2} ).

UPDATE: Forgot about encoding brackets in switchee regex, one of these should work:

{case value="#\d\d\d\d-\d\d#"}

or

{case value="#\d{4|-\d{2|#"}

The second version replaces the brackets with { for { and | for } .

4
  • I'm afraid switchee does not accept this characters, { }, in the regex.
    – worfoual
    Oct 8 '14 at 8:25
  • Thanks Romans, but what I want does work. On my first page with events it's working just perfect but if my URL is .../agenda/2014-11 I get a 404 page. I thought that Structure would work with switchee but it does not. Structure does understand the paging and when it's empty {case value="#^P(\d+)$#|''"} but not with a date yyyy-mm
    – worfoual
    Oct 8 '14 at 14:00
  • What is the exact value of the variable you're using in switchee where it's not working: /agenda/2014-11 ? Oct 8 '14 at 15:14
  • I use Structure and LowEvents. {exp:switchee variable="{segment_3}" parse="inward"} {case value="#^P(\d+)$#|''"} Listing agenda items by month. Structure ignore segment_3 is this one is a paging and I want structure to also ignore segment_3 if this one looks like yyyy-mm {/case} {case default="Yes"} Detail agenda items. If segment_3 is not a paging, not empty and not somethings like yyyy-mm show the detail of one item {/case}
    – worfoual
    Oct 9 '14 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.