HDAC
# or, for a more specific match
Name=HDAC
a) 82 (using the regex Name=HDAC[1-5][^0-9]
)
b) option iii) fits the description. You might also have chosen option ii), which would match the described pattern, but would also match other non-vowel letters in the middle two positions.
c) [A-z]
matches all letter characters (both upper and lower case). [a-Z]
is an invalid set. [A-9]
will match any letter or digit character.
chr[^XYM]
There are 897 records matching this regular expression. In fact, there are only 895 lines beginning with chr[^XYZ]
, but two other lines also match the regex above because they contain the string 'chromosome'. To avoid matching these, anchor the regex to the beginning of the line with ^
i.e. ^chr[^MXY]
(see chapter 3).
\d\d\.\d\d\.\d\d\d\d
There are 25 matches in the file person_info.csv
(every even record).
Note that there are a few caveats with that regex, such that it will also match strings like 131.01.20171 or 99.99.9999.
\b\d\d\.\d\d\.\d\d\d\d\b
Note that this prevents matching strings like 131.01.20171, but still allows non-sensical dates such as 99.99.9999.
While both regular expressions will prevent leading and succeeding digits, the regular expression \D\d\d\d\d\D
won't
work if the four digits appear at the beginning or end of the string. That is because the \D
tokens MUST
match a character.
^>.*transcript_biotype:protein_coding
There are 17 matches in the file example_protein.fasta
. Note: be careful when using >
in a regular expression on the command line - the >
symbol has a special meaning in many command line environments, and using it can result in accidentally wiping the content of files etc.
a) iv) the regex will match all of the strings i) - iii)
b) ATG?CT+CG
WL{3}Y
WL{2}Y
WL{1}Y
WL{1,4}Y
Use the regex ^(ENSP\d.+)
and substitute with >\1
.
Note that we explicitly match a digit character \d
. This is because E, N, S and P are all character of the amino acid alphabet and thus ENSP
can wrongly match protein sequences.
Use the regex Pictures\/(France-2015)\/
and substitute with shared/vacation-pics/\1-
.
[Ff]irst [Ss]treet|1st [Ss]treet
(Fir|fir|1)st [Ss]treet
a)
AGGCCA: 25
TGTGAC: 29
GCTGAC: 19
b)
regex: ^(AGGCCA|TGTGAC|GCTGAC)([ACGTN]+\n\+\n)
replacement string: \2
($2
)
c)
regex: ^(AGGCCA|TGTGAC|GCTGAC)([ACGTN]+\n\+\n).{6}
replacement string: \2
($2
)
d)
regex: ^(@VFI-SQ316.+:)GCGCTG\n(AGGCCA|TGTGAC|GCTGAC)([ACGTN]+\n\+\n).{6}
replacement string: \1\2\n\3