Tasks from section B and C - regular expressions. Deadline is till the end of November 22nd.
Please do all B tasks. These are the same tasks as A, but differ in the solution method. This time please use regular expressions.
When writing the solutions, please pay attention to the diffrence in complexity and execution time between regular expressions (B) and solutions based on basic mechanisms (A).
Each of you is assigned exactly 4 C tasks (in total these tasks will constitute an "easy task" with
section C, although you don't have to do them all).
Note: which task falls to you depends on the student index number! The tasks are grouped into 4 blocks:
- TaskC00-TaskC09 - the remainder from dividing by 10,
- TaskC10-TaskC36 - the remainder from dividing by 27,
- TaskC37-TaskC43 - the remainder from dividing by 7,
- TaskC44-TaskC48 - the remainder from dividing by 5.
Please check in the repository which task from each block is assigned to you. So each of you has exactly one task from each of these 4 blocks.
You can get a total of 16 points for the second laboratory.
## Regular expressions
We will do regular expressions based on python3. Documentation: https://docs.python.org/3/library/re.html.
### Basic functions
search - returns the first match in the substring
findall - returns a list of all matches (not overlapping)
match - returns the match from the beginning of the string
These are just the basic functions that we will use. The documentation describes them all.
### match object
```
import re
answer = re.search('na','banana')
print(answer)
print(answer.start())
print(answer.end())
print(answer.group())
answer = re.search('na','kabanos')
print(answer)
type(answer)
if answer:
print(answer.group())
else:
pass
```
### Metacharacters
- [] - set of characters
- . - any sign
- ^ - beginning of a string
- $ - end of the a string
- ? - the character preceding is or is not present
- \* - zero or more appearances of the character preceding
- \+ - one or more appearances of the character preceding
- {} - exactly as many appearances of the character preceding