What is a regular expression?

20

In many codes I see functions with a set of special characters that seem to have a function of their own.

I see this in almost every language, so what is it anyway, a class, a library, or what then?

Although there is a response in this question , in my point of view there may be a confusion of concepts when it is stated:

  

regex are finite deterministic automaton

That is, this answer does not answer this question in its basic concept.

A finite deterministic automaton is a finite state machine that in turn are recognizers of formal language types, one of them being regular expressions and it is about the latter that I look for definitions and characteristics in their implementations.

    
asked by anonymous 20.02.2017 / 08:34

2 answers

11

It is a string that defines a search pattern. It's an algorithm. We can say that it is a language for locating patterns in text.

It is not a programming language , but its implementation is available in virtually all standard language libraries or by a third-party library.

Some implementations are very simple having only one function, others have several classes with several utilities. Some languages preferred to embed it as a construction. There are variations of language. Some more more complete, others only with the main codes.

We can say that it is a design pattern , but since it is so old, so pervasive, that nobody nor does it define this way.

It is a way to get the location of text patterns within other texts through a sequence of codes that indicate how this pattern should be composed to fit what is sought. Other forms can be tedious, need larger codes, and the programmer can err more easily, although inexperienced programmers create multiple false positives if they do not test properly.

It is common to have functions, which in addition to locating makes the change of a pattern by some other text.

Normally it is abbreviated as regex or regexp .

    
20.02.2017 / 12:42
1

A regular expression is simply a set of characters that make a search pattern, for example, instead of writing the full name of a file, you can write the beginning of the name followed by the '*' character, so it will do reference to all items with this pattern.

    
20.02.2017 / 09:15