Skip to content

The basic use of REGEX (python,grep, websites…)

Posted in VIDEOS

Hello guys and welcome!

This time we will be talking a bit about REGEX. Regex or regexp is a regular expression, a sequence of characters that define a search pattern. Usually such patterns are used by string searching algorythms for “find” or “Find and replace” operations on strings or for input validation.

So in my video i display how i can access a part of my html file in linux using GREP which will exclude a specific part (the line) in which my “query” is, in this case the paragraph with email. This is an example of a search, you can use REGEX with GREP easily and exclude it for example with -w.

Then im displaying a python code:
import re

importing regex module

somestring = “my name is Jef. Jef is my name”
search_thing = re.findall(“Jef”, somestring)

a variable in which the search result will be stored,

we search using re.findall to find all matches

and then WHAT and WHERE(which string)

for k in search_thing:
print(“Result found:” ,k)

for each result found we will print it out

output:

> Result found: Jef

> Result found: Jef

-Right here we found 2 examples of “Jef”.

-Now lets jump on to the site, I would usually recommend regexr but i couldnt access it from some reason so im using regex101.

-Im using :
\w+@gmail.com
-To find emails

-Then im using:
\d{3}-\d{4}
-To find phone numbers

-Then lastly:
\d{2,3}.\d{2,3}.\d{2,3}.\d{1,3}
-To find IPs

-If you want to find ports too you can just add:

:\d{1,5}

-Matching this for example:
192.158.134.23:24423

And there we go; That is all for the basics.

Thank you so much for watching and Have a nice day !

Also visit me on Youtube if you are bored, or LBRY, or check out other posts! 😀