Regular expressions/regular language Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a regular expression?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A
  • ab : meaning a string consisting of symbol a followed by symbol b
  • ba : meaning a string consisting of symbol b followed by symbol a
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the notation a+ mean?

A

+ means pattern matches one or more “a”s going {a,aa,aaa,…}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the notation a* mean?

A
  • means pattern matches zero or more “a”s going {0,a,aa,aaa,…}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the notation ab?c mean?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the notation a | b mean?

A

means pattern matches the symbol “a” or the symbol “b”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the series of rules to follow?

A
  • operations + and * are highest priority and always carried out first
  • Concatenation is carried out next
  • operation | (or) is carried out last
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the definitions of the terms used for the following string searching?

  • Literal
  • Metacharacter
  • Escape character
  • Search Expression
A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a regular language?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly