---
title: "How to define pattern ?"
url: "https://openforis.support/questions/624/how-to-define-pattern"
tags: ["collect"]
status: "answered"
score: 0
answer_count: 1
asked: "2016-08-04T03:59:17"
last_activity: "2016-08-04T17:04:58"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# How to define pattern ?

Asked by Rajkumar on 2016-08-04

Hi openforis Team,
I am trying to use pattern in collect earth form. I tried to research input pattern in xml but I could not understand clearly because I could not get examples what I wanted. I am trying a pattern something like this e.g. (**MAK/BH/99/99**). My user will input in that pattern. Will you please give me example what pattern should I define ? thank you in advance.


## Answer (score 0, by Stefano (OF) on 2016-08-04)

Link: https://openforis.support/questions/624/how-to-define-pattern/625

Hi Rajkumar,  
The pattern you can define must be a *regular expression*. You can find a lot of documentation and tutorials in internet about that and even live regular expression tester (see for example [RegExr][1]). In Collect Survey Designer you can define a Pattern Check for a Text attribute so that the entered values will have to match the specified regular expression. In your case the expression can be this: 
`[A-Z]{3}\/[A-Z]{2}\/[0-9]{2}\/[0-9]{2}`  
That means: accept only 3 uppercase letters followed by a forward slash "/" (you have to escape it using a backward slash before it) then accept other 2 uppercase letters followed by "/" then 2 numbers and a forward slash and other 2 numbers.  
Also in the Message box of the Pattern Check please specify a meaningful error message for the users.
I hope this will help you.  
Thanks.  
Open Foris Team


  [1]: http://regexr.com

> Yes this worked for me.thank you very very much ricci. (Rajkumar)
