Regular expressions/regular language Flashcards Preview

Paper 1 - Computer Science > Regular expressions/regular language > Flashcards

Flashcards in Regular expressions/regular language Deck (10)
Loading flashcards...

What is a regular expression?

A notation used to describe a pattern of characters in an object or a set


Using a and b, what is the notation used for concatenation?

- ab : meaning a string consisting of symbol a followed by symbol b
- ba : meaning a string consisting of symbol b followed by symbol a


What does the notation a+ mean?

+ means pattern matches one or more "a"s going {a,aa,aaa,...}


What does the notation a* mean?

* means pattern matches zero or more "a"s going {0,a,aa,aaa,...}


What does the notation ab?c mean?

? means it matches the preceding character one or zero times, giving {ab,abc}


What does the notation a | b mean?

| means pattern matches the symbol "a" or the symbol "b"


What is the series of rules to follow?

- operations + and * are highest priority and always carried out first
- Concatenation is carried out next
- operation | (or) is carried out last


What are the string searching applications, regular expressions can be used in?

- Searching and locating files and folders
- Find or Search and Replace text strings in a block of text
- Parsing or analysing syntax in computer languages
- Searching for identifiers in a computer program
- Validation for entry fields in a database / online form
- Pattern matching with commands in an operating system


What are the definitions of the terms used for the following string searching?
- Literal
- Metacharacter
- Escape character
- Search Expression

- Literal - any character that is used in a search expression
- Metacharacter - these are special characters that have a unique meaning such as: ^ or *
- Escape character - using the \ (backslash) in front of a metacharacter allows it to be used in a search expression as a literal, for example: \^
- Search Expression - The regular expression that is used to find the target string


What is a regular language?

- A formal language that can be represented by regular expressions.
- A language that is acceptable for use by a finite state machine
- Regular languages have to be constructed from a finite number of states