Conversational modules
Programmable Channels
Platform functionality
Business segments
Industry verticals
Department
Our services
Solutions for telecoms
The Infobip advantage for telcos
See why leading telecoms around the world choose Infobip to transform their network
Telecom CPaaS partnerships
Create new B2B revenue streams with our omnichannel communications platform
Telecom core & security
Anam Protect Firewall
Secure your network from SMS and Voice fraud with our firewall that protects 120+ operators
SMS Firewall
Ensure all A2P SMS traffic is properly charged and eliminate revenue leakage with our SMS Firewall
Community & Resources
Knowledge hub
Title
What is Regular expression (Regex)?
A regular expression, shortened as Regex, and referred to as a rational expression, is a sequence of characters that specifies a search pattern.
String-searching algorithms commonly use these patterns for “find” or “find and replace” operations on strings and input validation. They are used in search engine search-and-replace dialogs of word processors and text editors, in text processing utilities, and in lexical analysis.
Many programming languages provide regex capabilities that are either built-in or via libraries.
Regular expressions, also called patterns, specify sets of strings required for specific purposes.
The most simplistic way to specify a finite set of strings is to list its elements. However, there are often more concise ways: for example, the set containing the three strings “geschaft”, “geschäft”, and “geschaeft” can be specified by the pattern g(ä|ae?)ft; it can be said that this pattern matches each of the three strings.
What is Regex used for?
Regex is mainly used for text-based searching and string manipulation but is also widely used in web development, data science, natural language processing, and text analytics.
How does Regex work?
Regular expressions are a sequence of characters that specify search patterns.
Regex is written using a combination of special characters and literal characters. These special characters allow regular expressions to find patterns in strings, while the literal characters are used as exact matches for specific words or phrases.
For example:
- Regex 9 matches “9”
- Regex four|4 accepts strings “four” or “4”
- Regex colou?r contains {color, colour}