Text (single line)

Definition and Options

This information type is suited when the answer should be text and is expected to be short. In computer science, this type is often called "string".

The additional options that apply are:

Option

Description

Minimum Length / Maximum Length

The minimum and maximum number of characters allowed for the answer.

Regular Expression / Example

Regular Expressions guarantee the provided answer conforms to a structure, like an email address.

Example

Provide an example for the user of an acceptable answer structure. More on this below.

Examples

Information fields where Text (single line) makes sense, are:

  • first name

  • email

  • street and number

  • profession

Regular Expression

This option is unique to the Text (single line) type. Using it allows atfinity to refuse invalid answers, based on their structure. atfinity accepts regular expressions in the JavaScript flavour as described on developer.mozilla.org. When you enter the pattern leave out any /, /g or /gi before and behind your pattern.

Example:

You get to a field that asks for an email address. You enter hbwqff4 and try to move on. But the system stops you, explaining your entry is not a valid email address. It tells you a valid answer should look like [email protected] . This is because the field has a regular expression provided that does not accept hbwqff4 as a valid email.

How to write regular expressions

Also called regex, regular expressions are very powerful but can be hard to write at first. To give you an idea, this is regex to validate the structure of an email address:

[\w.-][email protected][\w.-]+.\w{2,4}

This consists of five parts:

  1. At least one (signified by +) character (\w means letters and numbers) or "-"

  2. The "@" symbol

  3. At least one more character

  4. A "."

  5. Between 2 and 4 more characters

Usually, it's a good idea to reuse tested regular expressions. The website regexr.com provides a tool to build regular expressions. There, under 'Community Patterns', it contains a large library of expressions for almost every use-case. Just like the one above, all patterns can be copied freely.