How To Install libregexp-grammars-perl on Ubuntu 18.04

In this tutorial we learn how to install libregexp-grammars-perl on Ubuntu 18.04. libregexp-grammars-perl is Perl module to add grammatical parsing features to Perl 5.10 regexes

Introduction

In this tutorial we learn how to install libregexp-grammars-perl on Ubuntu 18.04.

What is libregexp-grammars-perl

libregexp-grammars-perl is:

Regexp::Grammars adds a small number of new regex constructs that can be used within Perl 5.10 patterns to implement complete recursive-descent parsing.

Perl 5.10 already supports recursive=descent matching, via the new (?…) and (?&name) constructs. This technique makes it possible to use regexes to recognize complex, hierarchical–and even recursive– textual structures. The problem is that Perl 5.10 doesn’t provide any support for extracting that hierarchical data into nested data structures. In other words, using Perl 5.10 you can match complex data, but not parse it into an internally useful form.

An additional problem when using Perl 5.10 regexes to match complex data formats is that you have to make sure you remember to insert whitespace- matching constructs (such as \s*) at every possible position where the data might contain ignorable whitespace. This reduces the readability of such patterns, and increases the chance of errors (typically caused by overlooking a location where whitespace might appear).

The Regexp::Grammars module solves both those problems.

There are three methods to install libregexp-grammars-perl on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install libregexp-grammars-perl Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install libregexp-grammars-perl using apt-get by running the following command:

sudo apt-get -y install libregexp-grammars-perl

Install libregexp-grammars-perl Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install libregexp-grammars-perl using apt by running the following command:

sudo apt -y install libregexp-grammars-perl

Install libregexp-grammars-perl Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install libregexp-grammars-perl using aptitude by running the following command:

sudo aptitude -y install libregexp-grammars-perl

How To Uninstall libregexp-grammars-perl on Ubuntu 18.04

To uninstall only the libregexp-grammars-perl package we can use the following command:

sudo apt-get remove libregexp-grammars-perl

Uninstall libregexp-grammars-perl And Its Dependencies

To uninstall libregexp-grammars-perl and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove libregexp-grammars-perl

Remove libregexp-grammars-perl Configurations and Data

To remove libregexp-grammars-perl configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge libregexp-grammars-perl

Remove libregexp-grammars-perl configuration, data, and all of its dependencies

We can use the following command to remove libregexp-grammars-perl configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge libregexp-grammars-perl

References

Summary

In this tutorial we learn how to install libregexp-grammars-perl package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.