Search

Hi guys,

Can anyone help me with the regular expressions in Symphony? I’m trying to set a validation rule for a date Text Input, and it’s not working.

I need the system to check if the user typed the following format: dd/MM/yyyy

I tried this:

(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}

But didn’t work.

What’s the right rules for the regex?

tia!

Is there any reason why you aren’t using the Date Field for this purpose?

Yes, there is. Here in Brazil we use the date like this: day/month/year

When I type for example 01/02/2010 (February 1st) it reads like: January 2nd. There’s any way to change it?

When you first install Symphony you can choose your Locale settings and the Date field, AFAIK, will display dates however you have specified.

By the sounds of it you’ve already installed Symphony, so you can change them manually in the config.php file found in your manifest folder.

The region array holds the information for displaying the time & date format, and your timezone. The formats are directly from the PHP Date manual and the PHP Timezone reference.

Thanks brendo, it works now!

Anyway, for futher needs, there’s some reference anywhere for the Regular Expressions of Symphony?

Expressões Regulares - Guia de Consulta Rápida (Portuguese)

Edit: Symphony does not have any specific regexp rules. It’s just the old and good regular expressions.

So Rainer, any tip for why that expression on my first post didn’t work?

Actually it works, you just forgot to put the slashes.

/^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}$/

Worked for you? For me it didn’t!

I’ve got a Text Input with the validation rule /^(0[1-9]|[12][0-9]|3[01])- /.- /.[0-9]{2}$/

I typed 23/02/2010 and it gives me 'Field Name' contains invalid data. Please check the contents.

I forgot to mention that you need to escape slashes and dots. See more here.

/^(0[1-9]|[12][0-9]|3[01])[- \/\.](0[1-9]|1[012])[- \/\.](19|20)[0-9]{2}$/

Now it should work.

Now it works perfectly Rainer. Thanks a lot!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details