In the past, I had no idea of Regex – what it is, what it means, what you can do with it. Now that I had to use GREP for my study (using regular expressions for Find/Change in InDesign documents), I found out that using Regex can be less complicated than expected. And because you can benefit from it in your DirectSmile Cross Media campaigns, I would like to share my Regex experience with you.
If you place a text input field on the page, you can enable a validation. There are different types of validation, e.g.: not empty (there must be any input, no matter what), date with specific format or mail address. The latter checks only if there is an @ inside the text input, not more.
Let’s have a look at some examples where we could need much more specific validation. OF course, this is just an examply. Once you know the regular expressions, you can use them for any kind of validation.
My colleague Nog wrote more information about how to use Regex in your DirectSmile Cross Media sms configuration here:
If you create a form that your colleagues can use to request a new e-mail address, you want to be sure that they enter the company e-mail address correctly. It would be great if the validation could not only check if the the e-mail address is anything@anything but email@example.com
Therefore you can use the validation type Regex. You will see a new tab:
We use this text field to define the input requirements. It should be firstname.lastname@example.org
The second part is easy, it should be the fixed text @yourcompany.com
The first part could be any text, so it needs a Regex for that:
Why .@yourcompany.com? Because . means that there must be any character.
That Regex would allow to type email@example.com but not firstname.lastname@example.org or only @yourcompany.com
Unfortunately it would also allow email@example.com
If you want to make sure that your colleagues fill out the form in that way: firstname.lastname@example.org
You need a Regex that allows anytext–email@example.com
The . can be any text. The backslash defines that there has to be the following character (in this case the hyphen) and the second . is again any text.
That Regex would allow firstname.lastname@example.org but not email@example.com or firstname.lastname@example.org
Unfortunately it would still allow email@example.com
Now if you know that your company e-mail addresses contain always a-z and definitely nothing else, you could also define that the text before and after the hyphen must be a-z. The Regex could look like this, but I’ll already let you know that this is not enough:
That Regex would allow firstname.lastname@example.org or email@example.com but not firstname.lastname@example.org
You see, [a-z] allows a character from a-z, but it allows only one character. To allow more than one, you can simply add a plus. A plus in Regex means that there is one or more of the previous character type.
This Regex will finally allow only text like email@example.com or firstname.lastname@example.org but not anything like email@example.com, firstname.lastname@example.org or @yourcompany.com
Finally, I hope I could show you that you can easily learn some regular expressions for your Cross Media campaign validation. Of course the world wide web is full of information about Regex, but most of them seemed to complicated for beginners like me. That’s why I started with wikipedia here, exceptionally, to get an overview of the basix Regex: