, 23 tweets, 7 min read Read on Twitter
Okay, so tomorrow is the day i do the thread on regular expressions. I will do the thread on everything on regexes for 2 popular languages : #Javascript & #Python. So, stay tuned for tomorrows tweets starting at around midday

cc @NellyTadi @Jayydubby @Patrick01_Codes
@NellyTadi @Jayydubby @Patrick01_Codes So sorry for the delay guys;

So, today i am going to be talking about regexs or regular expressions and how formulate them in 2 programming languages. We are going to start with the basics and from there we will look at the meta syntax combinations that come together to make...
...it possible to perform matches on strings (matching sequences) using patterns (formed by meta characters / meta syntax).

Regular Expressions are sequence of characters that define a pattern that is always finite, unambiguous or unaffected by context.
This is why they are called "context-free". A context free form is a form without ambiguity or impreciseness. Regular expressions form patterns that are precise, deterministic and whole. Given the same string having zero, one or more repetitive characters, a given regular...
...pattern will match consistently. You could also say that the pattern describes a formal grammar for a sequence of characters.

Regular expressions are made up of certain meta characters. These are characters we are already used to and connote meaning that pertain to the...
...matching sequences (string) that the pattern is meant for

These ASCII characters - e.g. "a", "[" , "]", "b", "u", "(", ")", ':") are characters that infer or target a matching sequences a.k.a a string which are the building blocks of any regular pattern you'll ever develop.
A matching sequence is actually the string that matches up with the pattern (regular pattern) formed by the regular expressions.

These meta characters have to be arranged in specific ways to achieve what is called the meta syntax. meta syntax follow rules...
...that are of "deterministic semantic consequence". That is to say that the one meaning of a meta syntax can never be altered under any condition. Furthermore, a meta syntax (when formed) means one thing and one thing only and so therefore can only match certain characters only.
There are 7 basic meta syntax for pattern discovery (discovery of a pattern) in any string (or sequence of characters) as far as regular expressions are concerned in any language.

They are as follows and are the bedrock of regular expressions either in #JavaScript OR #Python
1. character classes
2. parenthesized sub expressions (a.k.a groups)
3. look aheads (negated and non-negated)
4. look behinds (negated and non-negated)
5. back tracers
6. quantifiers
7. boundary checkers
It is important also to point out that a single meta character can be a meta syntax as we will see in "quantifiers" and "boundary checkers".

We will now go through these 7. once you learn these 7 met syntaxes, you are good to go!

Let's begin with CHARACTER CLASSES
Please go through what is in the image above in the tweet preceding this one, if you have any questions on CHARACTER CLASSES please let me know as a reply. I will answer all of them.

Remember character classes match single characters only in a string.
Next we move on to PARENTHESIZED SUB EXPRESSIONS which are high level meta syntax in regular expressions. They are so because they can hold (or nest) any other meta syntax within them as we will soon see how.

They are also very very closely associated with BACK TRACES a.k.a ...
... BACK REFERENCES (i omitted this earlier while listing the 7 meta syntax - sorry). Let's dive in and see how PARENTHESIZED SUB EXPRESSIONS are written and formed:
As before please go through what you have in the image on the tweet preceding this one. Got questions ? reply this tweet with them.

Let's look at more examples of PARENTHESIZED SUB EXPRESSIONS (this time, we will talk briefly on BACK TRACES / BACK REFERENCES too).
We see how BACK REFERENCES are used to refer to and/or reference other PARENTHESIZED SUB EXPRESSIONS. We also see that the number attached to a BACK TRACE / BACK REFERENCE is the ordinal count of the leftmost open bracket counted from the left of the pattern.

LOOK AHEADS next!
Still on still, if you don't completely understand my explanation for BACK TRACES for PARENTHESIZED SUB EXPRESSIONS, reply this tweet with your question and i will answer all of them.

Before we go to LOOK AHEADS, there is something worth mentioning about how to jump BACK TRACES
You ask - What do you mean by "jumping" BACK TRACES / BACK REFERENCES ?

So, when dealing with PARENTHESIZED SUB EXPRESSIONS, you may wish to ignore a given PARENTHESIZED SUB EXPRESSIONS by virtue of the count of its leftmost open bracket.

See this example below:
As before if you have any question please do ask.

Now, LOOK AHEADS are as the name implies do some "looking ahead" of a pattern you wish to match in a string (matching sequence).

LOOK AHEADS also have a certain property of matching only what precedes it.

See example below:
There are 2 types of LOOK AHEAD patterns.

1. a non-negated look ahead
2. a negated look ahead

Here is what it looks like:
We move on to LOOK BEHINDS which are just the opposite of LOOK AHEADS.

As before if you have any questions, you can ask as a reply to this question.

There are 2 types of LOOK BEHIND patterns.

1. a non-negated look behind
2. a negated look behind
Here is an example:
Now we move to BACK TRACES / BACK REFERENCES (which we spoke briefly about earlier) however for brevity. i'll skip this and move over to QUANTIFIERS.

If you would like to know more about BACK TRACES / BACK REFERENCES please find content on #WikiPedia
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Okechukwu Ifeora
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!