Nepedia
Back to Discover
Fluent Reader
💻

Regular expression

technology Maturity 7-9 Next article →

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
Stephen Cole Kleene

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
Thompson-kleene-star

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.

410 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (2)
File:Stephen Cole Kleene.jpg
Stephen Cole Kleene.jpg
File:Thompson-kleene-star.svg
Thompson-kleene-star.svg
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

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.