Skip to content
Snippets Groups Projects
Commit 7f29bba6 authored by Gilquin's avatar Gilquin
Browse files

fix: add Perl compatible grep regexp solution

The solution to the first character class exercise was wrong due to not using the appropriate grep flag (-E instead of -P).
parent 35675caf
No related branches found
No related tags found
1 merge request!2fix: correct some errors
......@@ -44,7 +44,7 @@ The program `grep string` allows you to search for *string* through a file or st
gzip -dc hg38.ncbiRefSeq.gtf.gz | grep "chr2" | head
```
What is the last annotation on the chromosome 1 (to write a tabulation character you can type `\t`) ?
What is the last annotation on the chromosome 1 ?
You can count things in text file with the command `wc` read the `wc` **man**ual to see how you can count lines in a file.
......@@ -54,7 +54,7 @@ How many transcripts does the gene *CCR7* have ?
## Regular expression
When you do a loot text search, you will encounter regular expressions (regexp), which allow you to perform fuzzy search. To run `grep` in regexp mode you can use the switch. `-E`
When you do a loot text search, you will encounter regular expressions (regexp), which allow you to perform fuzzy search. To run `grep` in regexp mode you can use the switchs `-E` or `-P` for Perl regexp.
The most basic form fo regexp si the exact match:
......@@ -90,7 +90,11 @@ Search for two digits followed by an uppercase letter and one digit.
<details><summary>Solution</summary>
<p>
```sh
gzip -dc hg38.ncbiRefSeq.gtf.gz | head | perl -E "\d\d[A-Z]\d"
gzip -dc hg38.ncbiRefSeq.gtf.gz | grep -E "[0-9][0-9][A-Z][0-9]"
```
We need to use the flag `-P` to use the character class `\d`:
```sh
gzip -dc hg38.ncbiRefSeq.gtf.gz | grep -P "\d\d[A-Z]\d"
```
</p>
</details>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment