Regex is like an egg

Hi my all are dev & tech beautiful friends

you're thinking🤔 why I've written the title of regex is like an egg no worries I'll be explaining that

a little bit of introduction of egg 🥚

Both the white and yolk of an egg are rich in nutrients, including proteins, vitamins, and minerals. The yolk also contains cholesterol, fat-soluble vitamins (such as vitamins D and E), and essential fatty acids. Eggs are also an important and versatile ingredient for cooking wait! ✋ wait!

no worries, it's neither a food article nor I'm a food expert

as we know that the egg is very important in our health and the regex is important part of programming language.

my meet with regex

as a beginner, we have a lot of confusion about the programming language different concepts include with regex. personally, I had a little bit scared about the regex. that's why I tried to learn as much as possible. and I figured out the regex is how cool is that.

What Is a Regular Expression?

🗣️w3schools says

A regular expression is a sequence of characters that forms a search pattern.

When you search for data in a text, you can use this search pattern to describe what you are searching for.

A regular expression can be a single character or a more complicated pattern.

Regular expressions can be used to perform all types of text search and text replace operations.

It is used in almost all languages like C#, Java, Javascript, To, Python, so on.

if you want to learn more check out the link below 👇
Regular expressions javascript.info
Regular expressions MDN
Regular expressions w3schools

Regular Expression with Java, javaScript, python

in this article I'm not going to be teaching you the Regular Expression.
we would try to explore the regex with problem-solving also understand how does regex work.
I hope it would be better for us to understand the regex.

below is the Problem Statement

let's do solve with javascript

// forward-slash: in the javascript, we can write regex Pratten Through forward-slash also constructor function, it's calling literal /ab+c/ another it's calling constructor new RegExp('ab+c').

0+ 0 is our expected value and + it's calling Quantifiers, The plus sign indicates one or more occurrences of the preceding 0 element.
g flag modifier it means g is a modifier global flag
Note:in the javascript If the regex does not include the g modifier (to perform a global search), the match() method will return only the first match in the string.

The match() method searches a string for a match against a regex, and returns the matches, as an Array object, returns null if no match is found.

we got likes this [000] from zero and one [1111]
as we saw that the match() method returns null if no match is found. that's why we used after ||or operator it helps to convert the null to the empty array [] after parentheses to grouping the expression we used join() method it helps to convert to the string likes this '0000' and '1111'

now we explore return it just returns boolean value because we subtracted with zero and one length inside of math.abs function and meth.abs function return absolute value after that we compared less than or equal 1 or not this’s our solution with regex.

below is the Problem Statement

let's do solve with python

whatever, at first we've taken the variables name of decoded after InstallShield with regex method re.findall().
findall(pattern, string, flags=0) method has up to three arguments.
The findall() is probably the single most powerful function in the re module. findall() finds *all* the matches and returns them as a list of strings, with each string representing one match.
note: If no matches are found, an empty list is returned.

then we have used the pattern[a-zA-Z1-9] a-z it means given the ipute a to z any alphabetic smil latter and as same as that A-Z any alphabetic capital letter also 1-9 it means 1 to 9 any number to the match. if we can use flag I we don't need to mention capital and smail latter.
however, we got this ['John', 'Doe', '123'] from decoded as a list now we can easily use with dictionary and we did that.

below is the Problem Statement

let's do solve with java

end of this article: Keep Learning

That’s the end of this article, but keep learning and practicing.

I've tried to a couple of examples with solved the problem, because if we see some use cases it really helpful for us to understanding any particular concept that's why I solved the problem by exploring how does work regex.

I don't know could I explain properly or not but I tried as much as possible to explained. if I've mistaken anything please share it with me I'll correct it.

I really passionate about sharing my knowledge Through write an article and in the future, I'll try to write another concept article until stay safe.

happy coding✌️

7