Pin Me

The Use of Regular Expression in Perl

written by: Finn Orfano • edited by: Leigh A. Zaykoski • updated: 6/19/2008

This article discusses the concept of regular expressions and how they are used in relation to the programming language Perl.

  • slide 1 of 1

    Before understanding how to use regular expression in bioinformatics, one must first have an understanding of what regular expressions are. Regular expressions are a way of describing a pattern. Creating a pattern is an interesting feature of Perl. In some cases, we use the same character to create a pattern, or for testing a pattern. However, in Perl we can also use some special symbols known as meta-characters. Meta characters indicate a group of similar characters or that match a special position in a string.

     
    Regular expressions are mainly used to match, substitute or translate characters. Without these regular expressions, Perl would be a fast developPerl CGI and Web Programmingment environment. Mainly regular expressions are used for string comparisons.

     
    Regular expressions in Perl have three important operators: the match operator, the substitution operator, and the transliteration operator. The match operator is used to match a string if a particular pattern is present or not. If that pattern is present, then it will return true, and if it is not present, then it returns false. So, the main function of the match operator is to match the given pattern of a string. The substitution operator is used to substitute the pattern with another given pattern. It is mainly used to substitute one letter, or one string, with another letter or string. The transliteration operator is used to transliterate, or translate, the text or strings present in a file.

     
    These operators are used for managing biological data. For example, translation is done by replacing A with U, G with C, and T with A and C with G. This is possible with the transliteration operator. This operator is used to translate the given text with the other.

    Sometimes, these operators are used to find the restriction sites. Here, the match operator is used to find the presence of restriction patterns. Therefore, regular expressions play an important role in solving different biological problems.

    Interested in learning more about Perl? Read these articles:

    Perl CGI and Web Programming

    Using Perl for Bioinformatics