Log in Sign up
Back to Discover
💻

Regular expression

technology Maturity 7-9

Computers use patterns to find words.

Thompson-kleene-star.svg
Thompson-kleene-star.svg
These patterns help search for things. You can find a word fast. It helps us fix mistakes in text. It is a very smart tool. Do you like to search for things?

39 words

Computers use special patterns to find words.

Thompson-kleene-star.svg
Thompson-kleene-star.svg
These patterns help a computer search through text. You can use them to find a word. You can also use them to change a word.
Stephen Cole Kleene.jpg
Stephen Cole Kleene.jpg
A man named Stephen Kleene helped start this idea. He worked on these rules in the 1950s. Now, many programs use these patterns every day. They help us find things very fast. It is a very smart tool for computers.

76 words

Computers use special patterns to find text. We call these patterns regular expressions. People often call them regexes for short.

Stephen Cole Kleene.jpg
Stephen Cole Kleene.jpg
A mathematician named Stephen Cole Kleene started this idea. He worked on it in the 1950s.

A regex is a sequence of characters. These characters tell a computer how to match text. Some characters are literal. This means they match themselves. For example, the letter 'b' matches only 'b'. Other characters are metacharacters. These have special meanings. A dot is a metacharacter. It can match almost any single character.

Thompson-kleene-star.svg
Thompson-kleene-star.svg

You can use these tools to find or change words. They can also check if input is correct. You can use symbols to show how many times a letter appears. An asterisk means zero or more times. A plus sign means one or more times. A question mark means zero or one time. These rules help search engines and text editors work fast. Many programming languages use them today. Some new tools even use special hardware to make them faster.

173 words

Computers often need to find specific patterns in a sea of text. We call these patterns regular expressions, or regexes for short. They are more than just simple words. A regex is a sequence of characters that tells a computer exactly what to look for. You might use them to find a word or to change it. They are also used for input validation. This means checking if information is typed in the right way.

Stephen Cole Kleene.jpg
Stephen Cole Kleene.jpg
Regular expressions help make searching much faster and smarter.

How does a regex actually work? It uses two different kinds of characters. Some are literal characters. These match themselves, like the letter 'b' matching only 'b'. Others are metacharacters. These have special meanings that act like instructions. For example, a dot is a metacharacter that matches almost any single character. You can also use symbols to show how many times something repeats. A question mark means zero or one time. An asterisk means zero or more times. A plus sign means one or more times.

Thompson-kleene-star.svg
Thompson-kleene-star.svg

The idea for these patterns began in the 1950s. An American mathematician named Stephen Cole Kleene first described them. He used them to talk about regular languages. This work came from the study of computer science. Later, these tools became very popular in the 1960s. They were used for matching patterns in text editors. They were also used to help computers understand programming languages. This helped make the early days of computing much more powerful.

Many famous computer scientists helped build these tools. Ken Thompson was one of the first to put them into a program. He built them into an editor called QED. He even used a special method called just-in-time compilation to make them fast. This was done on an early system called the IBM 7094. Later, different standards were made, like the POSIX standard in 1992. In the 1980s, the Perl language added even more complex features. These ideas were built on work by people like Henry Spencer.

You likely use regexes every single day without knowing it. They are inside search engines that help you find websites. They are also in word processors when you use "find and replace." Many programming languages, like Python and Java, have them built in. Even modern web servers use them to work correctly. Some new companies even make special hardware to run them faster. They are a tiny but vital part of how our digital world stays organized.

412 words

A regular expression, often shortened to regex or regexp, is a sequence of characters that defines a specific match pattern within text. These patterns allow computers to perform complex string-searching tasks. They are commonly used for "find" or "find and replace" operations. They also serve as tools for input validation, which ensures that typed data follows a specific format. In the field of theoretical computer science, regular expressions are a fundamental part of formal language theory. They provide a way to describe and classify different types of languages through mathematical notation.

To understand how a regex works, you must distinguish between two types of characters: literal characters and metacharacters. A literal character has a fixed meaning. For example, the letter "b" in a pattern will only match the letter "b" in the text. Metacharacters, however, act as instructions that represent broader rules. A dot (.), for instance, is a metacharacter that matches any single character except for a newline. By combining these, you can create very precise or very general patterns. A pattern like "seriali[sz]e" can match both "serialise" and "serialize" by using brackets to offer a choice.

Thompson-kleene-star.svg
Thompson-kleene-star.svg

Regular expressions use several specific operations to build complex rules. One common method is Boolean "or," which uses a vertical bar to separate different choices, such as "gray|grey." Another method is grouping, which uses parentheses to define the scope of these operators. Quantification is also essential. This tells the computer how many times a character or group should repeat. The question mark (?) indicates zero or one occurrence. The asterisk (*) represents zero or more occurrences, a concept known as the Kleene star. The plus sign (+) indicates one or more occurrences. You can even specify exact numbers, such as requiring a character to appear exactly five times.

Stephen Cole Kleene.jpg
Stephen Cole Kleene.jpg

The history of these patterns began in 1951 with the American mathematician Stephen Cole Kleene. He formalized the concept of regular languages while working in the subfields of automata theory and formal language theory. His work was originally motivated by attempts to describe early artificial neural networks. By 1968, regular expressions entered popular use in two main areas: pattern matching in text editors and lexical analysis in compilers. Ken Thompson was a key figure in this era. He integrated Kleene's notation into the QED editor. Thompson even used just-in-time compilation on an IBM 7094 system to make the matching process faster.

Thompson's work eventually led to the creation of the Unix editor "ed" and the famous search tool "grep." The name "grep" actually comes from the command "g/re/p," which stands for "Global search for Regular Expression and Print." During the 1970s, various versions of these expressions were used in Bell Labs programs like sed and AWK. In the 1980s, more complex versions emerged through the Perl language. This was built upon work by Henry Spencer, who wrote an implementation for Tcl called Advanced Regular Expressions. These different paths led to various standards, such as the POSIX.2 standard established in 1992.

Stephen Cole Kleene.jpg
Stephen Cole Kleene.jpg

Today, the significance of regular expressions is seen in almost every corner of computing. They are used in search engines and in the "find and replace" dialogs of word processors. Many programming languages, including Java, Python, and ECMAScript, include regex support in their standard libraries. Even large-scale web infrastructure relies on them; for example, Philip Hazel developed PCRE (Perl Compatible Regular Expressions) in 1997, which is used by the Apache HTTP Server. In recent years, the demand for speed has led companies to develop specialized hardware, such as FPGAs and GPUs, to run these engines even faster than a standard CPU.

Regular expressions connect to many broader technical systems. They are used in lexical analysis, which is the process of helping a compiler understand a programming language. They also play a role in document and database modeling. Since the 1960s, industry standards like ISO SGML have used the kernel of regular expressions to specify structures. Even modern languages like Raku use "Raku rules" to allow for more advanced parsing. From simple filename "globbing" to the complex logic of modern software, regular expressions remain a vital tool for organizing and processing the world's digital information.

697 words
🖼️ Images & Media (2)
File:Stephen Cole Kleene.jpg
Stephen Cole Kleene.jpg
File:Thompson-kleene-star.svg
Thompson-kleene-star.svg
Up Next
💻
Perl
Technology
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.