Regular expressions

Created by Aneta Węglarz, Modified on Thu, 28 Mar at 3:10 PM by Aneta Węglarz

What are regular expressions?

Regular expressions are sequences of characters that define patterns for searching within text. They allow for flexible and advanced searching, matching, and manipulation of textual data.

Filtering

The primary use of regular expressions is data filtering. This can involve extracting specific patterns from text or eliminating fragments that do not meet certain criteria.


Create rule

Not only for filtering, but regular expressions can also be used for generating rules on a chosen attribute. This is useful in the process of transforming data contained in individual columns, where we want to replace phrases with others.

Basic regex syntax

Regular expression syntax (regex) includes several key elements that are worth knowing to effectively use this tool. Here are a few basic regular expressions:

Characters


. - matches any single character (except newline)

\d - matches any digit

\w - matches any alphanumeric character

\b – word boundary

^ – start of sequence

$ – end of sequence

Examples:


Below are a few regexes:

“s” - finds the letter “s”


Sembot Ads Suite


^Se - finds a string starting with "Se"


Sembot Ads Suite



Quantifiers;


* – matches 0 or more occurrences

+ – matches 1 or more occurrences

? – matches 0 or 1 occurrence

{} – matches an exact number of characters


Examples:


"a?b+$" - possible "a", followed by one or more "b" at the end of the sequence

aa, ab, abb, abbbb, ac, abcd, abbc, accd, acd, acdb, acabb

Grouping:


[ ] – matches all characters in brackets

[^ ] – matches all characters outside the brackets

() – grouping

| – or


Example:


“[A-Z. ]” – find all capital letters, dots, and spaces

Sembot Ads Suite is an excellent tool for managing online ads.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article