This week you get to work on some more regex examples.
You can create documents and edit them directly in GitHub's web interface. This is a very convenient way of creating and editing the files. In most cases, the preferred way of working is to create and edit the files on your own machine.
In the next weeks we will have to work with files in a programme (R and R Studio) that we will install on our machines, so GitHub Desktop will become the preferred way of working on our repositories. To get used to GitHub Desktop please make at least one of your commits through GitHub Desktop. You can do all your commits in GitHub Desktop if you want.
Below is today's task. We will be working with regular expressions. If you want a reminder how regular expressions work you can watch parts of the first regex class on YouTube.
For this task, you need to provide the answers in the file you are currently reading. It is a Markdown file. More explanations about the Markdown syntax can be found on GitHub's Mastering Markdown page.
- Under the heading Your Task you will find several questions.
- Try to find the regular expressions needed to fulfil the criteria.
- You might want to use Notepad++ or a website like regular expressions 101 or RegExr to test your regular expressions.
Commit early, commit often - that way you can go back if you have made a mistake and I can see all the work you have done. It doesn't matter if your early commits contain mistakes.
Once you are done be sure to commit your changes (that will save them to the repository) and to push them to GitHub (so that I can see the work you have done).
You have to work on this task individually.
Reminder:
a
will match the character a
[ab]
will match the character a or b
[a-z]
will match the characters in the range between a and z
Think of different formats of writing down prices in Pounds and Euros and write down your answer to this question (one per line).
Example: €149.95, £150, ...
Answer: Replace this text with your answer.
Find a regular expression that will match the prices in Pounds and Euros (from your previous question).
If you cannot match all try to match as many as possible. If you can't match all, don't change Question 1 by pretending you came up with fewer price formats, but you matched them all. It's better if you come up with lots of formats you can't match than if you only come up with very few formats, but you can match all.
Hint: Unless the way your regular expression works is obvious, please explain how it works, e.g. x will match the character x and y makes sure it also works under circumstances z.
Answer: Replace this text with your answer.
Find a regular expression that will only match prices under £150 and under €150.
Hint: €149.95 should get matched, but £150 should not get matched. Unless the way your regular expression works is obvious, please explain how it works.
Answer: Replace this text with your answer.
Find a regular expression that will match a typical UCLan email address.
Hint: Unless the way your regular expression works is obvious, please explain how it works, e.g. x will match the character x and y makes sure it also works under circumstances z.
Answer: Replace this text with your answer.