I happened to watch this below video which was explained with awesomeness.It is around an hour playing video. This guy has some magic really.
When you are start playing this video,
you will get started to hear surprises!!
Q1. What is regular expression?
Here I think you will get out :-( i was also Regex is not a descriptive language of what we think..I don't what to think..anyway my perception went wrong. So, Regex is just a code and blocks which has it's own dialect to execute the code/block/functions.This dialect is playing the role of virtual machine.The regex dialect has control flows, commands, exception handling.
Q2.What are the rules of regex engine?
Rules means the working mechanism what is follows. we have to understand it's rule.So, that will be helpful when spitting some matched result, you can wipe it without any whip.
The engine does when applying the pattern to the input string
- The earliest possible substring is first than the Best possible string.
- The pattern is always given preference to the leftmost/uppermost pattern among the others.
Q3. What regex dialect are we using generally?
PCRE (perl 5)
It is time to enter into the main picture.
The very very important things are coverd here is,
How is this engine works?
import re re.findall('abc','abcdef')
They are introducing a concept called ‘BackTracking’ which is nothing but, if there is an exception or unmatched for first character of the string, the loop will be started again from the next character.The control will be started from initally for each character untill it found the match.
He is talking about execution model also.
* It will give you some amount of wonder if you listen carefully. * Graph traversal is being done here. * Also, NFA, DFA algorithms also used and explained with order of complexity. * How minimal matching and Greed matching works?
Alert, Greed is always bad!! everywhere even in regex too. 🙂
(if you are doing greedy regexing(+, *) for 2gig file, your machine knows the pain)
backtracking raises, system falls
Unfortunately, I could not cover everything in detail here.I am sharing the video link.Hope you will enjoy and share the enjoyment 🙂