Frequently Asked Questions

  

What is a Regular Experession?

A regular experession is a piece of code which can be used to check that data matches an expected pattern. Regular expressions are 'cheap' to use and are a great way for checking that user input is valid. For example, in the form on this site, if users try and enter a name which contains numbers, the problem is identified by a regular expression and and error is generated. Having said that, regular expressions are limited, they cannot 'loop' and can't be used to check a full date (dd/mm/yyyy). Whilst a regular expression can check for a date like pattern, it is not able to make sure that the date is valid (eg: 29/02/2017 is invalid - but a regular expression would not be able to detect this). Regular expressions cannot be used to ensure that an expression which includes brackets has been well formed (ie: it can't check that all open brackets are closed).

  

What is a Context Free Grammar?

Context Free Grammar A Context Free Grammar is both more expensive and more powerful than a regular expression. Context Free Grammars can be used to describe all possible strings in a formal language, included those which have brackets. Unlike regular expressions, context free grammars cope well with recursion. A grammar is 'context free' when the relationship is one to one, one to many or one to none (many to one relationships are not allowed). One interesting thing about context free grammars is that rules can be applied in reverse to check that they are valid. Note that not all languages can be described by context free grammars.

  

What is a Context Sensitive Grammar?

The short version is that context sensistive grammars are more general than context free grammars but less general than an unrestricted grammar. At this stage, we really don't want to go further than this! Unless you are a fan of formal languages and can get your head around the notation associated with them. In that case you can read more at the preceding link.