Regular Expressions

How do they works?

Attached: CG-Society-Wizard-Magic.jpg (1486x1600, 498K)

Other urls found in this thread:

youtube.com/watch?v=ptyksCGBBn4
robelle.com/smugbook/regexpr.html#expression
regular-expressions.info/engine.html
twitter.com/NSFWRedditVideo

Formal
Languages
youtube.com/watch?v=ptyksCGBBn4

like capitalism by greed most of the time.

type "man grep" in your terminal

This is me using regular expressions

Attached: 9238be8625e38d36b6e8a4b6fa80c211.jpg (1067x1600, 151K)

Actually do it, and scroll down to Anchoring...

:^)

regex101 (Google it)

That website lets you test regex and explains what every single character is doing. Just find something you need to do with it and mess around, eventually you'll learn. It's pretty easy too.
Here's an example: try using regex to extract the video id from a YouTube video:

youtube.com/watch?v=XXX&YYY... should return XXX only. I had to do this for work very recently.

type "man grep | grep grep"

Regular expressions aren't that difficult, but it's made more tedious due to the fact that the syntax is different for many languages and text editors.
Now the question is if you want to learn the formalism of regular expressions or just want to learn by doing. What is an operator and why was it chosen? Read on to learn about it.
If you like the idea of regular expressions, that means more than just regular expressions. I'd encourage every programmer who wants to learn regular expressions to start at the beginning, to learn about this subject on their own from now on and learn all the details before diving into the official website. I hope you will find this post helpful. If so, don't forget to share it if you liked it! Have fun learning Regular Expressions .

Yeah, I wasn't even joking

robelle.com/smugbook/regexpr.html#expression

Attached: index.jpg (300x168, 6K)

But youtube video IDs have more than 7 characters. Your example makes no sense.

Example: ptyksCGBBn4

I create regular expressions every day at work, needless to say I've become pretty good at it. I can solve any regex golf problem you throw at me. I'm currently at the point where I wish there was a regex engine with more advanced features..

also wildcards;
* anything
? any single char
th{is,at} this or that
[Mm]ozilla Mozilla or mozilla

Attached: CopyQ.qMuFJj.png (328x167, 9K)

>also wildcards;
>* anything
>? any single char

Niggam what

* = zero or more
? = makes the search lazy (matches as few as possible)

>also wildcards
Not regex, bash wildcards.

Depends on the implementation. Mostly, you can tell by whether they support backtracking. But modern regex implementations often fall back to simple comparison functions for cases where you don't need anything overly complex.

See regular-expressions.info/engine.html

oh..

I guess I need to sleep.

THE SMILE WITH THE CARET NOSE

How do i implement my own Regex? I know about turning regex into NFA with e-closures, that would be dict in my case. Problem is: '*' or '+' operator could be either after single letter or after, parenthised expression. Same with '|', there could be: 'a|b', or ' (a|...) | (b|...)' or any other configuration.
Also how do I eval parenthised expressions? Probably by recursion: call function on '(something)' until there is no longer '()', but evalParenthis function is same as evalRegex itself, because inside parenthesis there could be regex of any length.
How do I start? I can't look at every character, looking for parenthesis and take care of them at first, then somehow (?) connect all graphs into one. Scanning each character seems silly too. It looks like I should build some look ahead parser, but I always used yacc for that so I don't know how to do it without regex itself.
Holy shit, I programmed NFA to DFA conversion before, and I can match strings against them, so i thought I could be able to go step ahead and build regex on top of it, but boy it is difficult.
Any of you guys can give me some hints.
While I google for "regex to NFA conversion" there are tips to converting each operation into simple automata, but I can't find straight algorithm for parsing regex of any length, dividing it into some smaller operations like 'a|(b|c)*' , making it into automata, and appending to resultAutomata (in my case dictionary)

I can post my python automata code I am basing this on, tomorrow because I am in bed now

thanks for the flashbacks
t. philosophy major

=\K.{3}