Regular Expression in Perl

What is Regular Expression in Perl?


Regular expressions are that makes Perl an ideal language for "Practical extraction and reporting" as the name implies.To construct the regular expression, which is essentially a sequence of characters describing the pattern you would like to match. In MS-DOS we use "*.txt" to get all text files, we say this as a pattern, likewise perl uses a set of regular expressions that can be used to specify the patterns, so you can make your search more specific.

After creating a regular expression perl uses binding operators like (=~ or !~) to bind the data to be searched for. Let us see a example.

Perl is used in number of ways:

  • Search for a string that matches a specified pattern
  • Optionally replacing the pattern found with some other strings
  • Counting the number of occurrences of a pattern in a string
  • Split a formatted string (e.g. a date like 02/06/2001) into day, month and year
  • Validation of fields received from HTML forms by verifying it to a particular format

Ask Questions

Ask Question