Difference between revisions of "Regular expression"
Karl Jones (Talk | contribs) (→See also) |
Karl Jones (Talk | contribs) |
||
Line 18: | Line 18: | ||
Regular expression processors are found in several [[Web search engine|search engines]], search and replace dialogs of several [[Word processor|word processors]] and [[Text editor|text editors]], and in the command lines of text processing utilities, such as [[sed]] and [[AWK]]. | Regular expression processors are found in several [[Web search engine|search engines]], search and replace dialogs of several [[Word processor|word processors]] and [[Text editor|text editors]], and in the command lines of text processing utilities, such as [[sed]] and [[AWK]]. | ||
+ | |||
+ | == Examples == | ||
+ | |||
+ | Remove pairs of square brackets and their contents: | ||
+ | |||
+ | <code> | ||
+ | \[[^\[]*\] | ||
+ | </code> | ||
+ | |||
+ | Source: [https://stackoverflow.com/questions/43246115/java-regular-expression-matching-square-brackets/43246127 Stack Overflow] | ||
== See also == | == See also == |
Latest revision as of 06:50, 4 May 2019
In theoretical computer science and formal language theory, a regular expression (abbreviated regex or regexp and sometimes called a rational expression) is a sequence of characters that define a search pattern.
Contents
Description
This search pattern is used for pattern matching with strings, or string matching, i.e. "find and replace"-like operations.
History
The concept arose in the 1950s, when the American mathematician Stephen Kleene formalized the description of a regular language, and came into common use with the Unix text processing utilities ed, an editor, and grep (global regular expression print), a filter.
Standards
Regular expressions are so useful in computing that the various systems to specify regular expressions have evolved to provide both a basic and extended standard for the grammar and syntax.
Modern regular expressions heavily augment the standard.
Regular expression processors
Regular expression processors are found in several search engines, search and replace dialogs of several word processors and text editors, and in the command lines of text processing utilities, such as sed and AWK.
Examples
Remove pairs of square brackets and their contents:
\[[^\[]*\]
Source: Stack Overflow
See also
- Comparison of regular expression engines
- Computer science
- Extended Backus–Naur Form
- Formal language
- List of regular expression software – applications which support regular expressions
- Pattern matching
- Ragel
- Regular tree grammar
- Search pattern
- String (computer science)
- Theoretical computer science
- Thompson's construction algorithm – converts a regular expression into an equivalent nondeterministic finite automaton (NFA)
External links
- Regular expression @ Wikipedia